config-top.h
- EXIT_ON_SETUID_FAILURE: new settable define, will cause the shell to
exit if setuid fails with errno == EAGAIN
+
+ 6/10
+ ----
+parse.y
+ - time_command_acceptable: fix so time is accepted everywhere the
+ grammar is looking for a `compound_list'. Fixes bug reported by
+ Dale Worley <worley@alum.mit.edu>
+
+ 6/12
+ ----
+subst.c
+ - clear_fifo_list: new function, clears FDs associated with open pipes
+ in current FIFO list without closing the file descriptors. Can
+ possibly be used when shell_execve fails and the shell jumps back
+ to top_level and we don't want the shell to close the open FIFOs
+ each time through the read-execute loop. Bug reported by Harald
+ Koenig <koenig@tat.physik.uni-tuebingen.de>
+
+
+ 6/16
+ ----
+builtins/shopt.def
+ - compat42: make sure the `compat42' option sets the correct variable
+ for compatibility level. Fixes bug reported by Ondrej Oprala
+ <ooprala@redhat.com>
+
+support/bashbug.sh
+ - fix typo when echoing $USAGE. Report from Shantanu Kulkarni
+ <djbware@shantanukulkarni.org>
--- /dev/null
+ 2/14/2011
+ ---------
+[bash-4.2 released]
+
+ 2/15
+ ----
+lib/glob/gmisc.c
+ - fix wmatchlen and umatchlen to avoid going past the end of the
+ string on an incomplete bracket expression that ends with a
+ NUL. Partial fix for bug reported by Clark Wang <dearvoid@gmail.com>
+
+ 2/16
+ ----
+subst.h
+ - new string extract flag value: SX_WORD. Used when calling
+ extract_dollar_brace_string to skip over the word in
+ ${param op word} from parameter_brace_expand
+
+subst.c
+ - change parameter_brace_expand to add SX_WORD to flags passed to
+ extract_dollar_brace_string
+ - change parameter_brace_expand to use SX_POSIXEXP for all non-posix
+ word expansion operators that treat single quotes as special, not
+ just % and #
+ - change extract_dollar_brace_string to initialize dolbrace_state to
+ DOLBRACE_WORD if SX_WORD flag supplied and we shouldn't use
+ DOLBRACE_QUOTE. Fixes bug reported by Juergen Daubert <jue@jue.li>
+
+doc/{bash.1,bashref.texi}
+ - document the exact expansions here strings undergo
+
+ 2/17
+ ----
+lib/readline/vi_mode.c
+ - make sure that `dd', `cc', and `yy' call vidomove_dispatch from
+ rl_domove_read_callback. Fixes bug reported by Clark Wang
+ <dearvoid@gmail.com>
+
+lib/readline/callback.c
+ - make sure _rl_internal_char_cleanup is called after the
+ vi-motion callbacks (rl_vi_domove_callback) in rl_callback_read_char.
+ Companion to above fix
+
+doc/{bash.1,bashref.texi}
+ - make sure that the text describing the rhs of the == and =~
+ operators to [[ states that only the quoted portion of the pattern
+ is matched as a string
+
+ 2/18
+ ----
+lib/glob/gmisc.c
+ - better fix for umatchlen/wmatchlen: keep track of the number of
+ characters in a bracket expression as the value to increase
+ matchlen by if the bracket expression is not well-formed. Fixes
+ bug reported by Clark Wang <dearvoid@gmail.com>
+
+subst.c
+ - change expand_string_for_rhs so that it sets the W_NOSPLIT2 flag
+ in the word flags. We will not perform word splitting or quote
+ removal on the result, so we do not want to add quoted nulls if
+ we see "" or ''. Fixes bug reported by Mike Frysinger
+ <vapier@gentoo.org>
+
+ 2/19
+ ----
+variables.c
+ - new function, int chkexport(name), checks whether variable NAME is
+ exported and remakes the export environment if necessary. Returns
+ 1 if NAME is exported and 0 if not
+ - call chkexport(name) to get tzset to look at the right variable in
+ the environment when modifying TZ in sv_tz. Don't call tzset if
+ chkexport doesn't indicate that the variable is exported
+
+variables.h
+ - new extern declaration for chkexport
+
+
+{parse.y,builtins/printf.def}
+ - call sv_tz before calling localtime() when formatting time strings
+ in prompt strings or using printf. Fixes bug reported by
+ Dennis Williamson <dennistwilliamson@gmail.com>
+
+execute_cmd.c
+ - modify fix of 2/9 to add casts when those variables are passed to
+ functions; some compilers throw errors instead of warnings. Report
+ and fix from Joachim Schmitz <jojo@schmitz-digital.de>
+
+support/shobj-conf
+ - add a stanza for nsk on the Tandem from Joachim Schmitz
+ <jojo@schmitz-digital.de>
+
+{shell,lib/readline/shell}.c
+ - Tandem systems should use getpwnam (getlogin()); for some reason
+ they don't do well with using getuid(). Fix from Joachim Schmitz
+ <jojo@schmitz-digital.de>
+
+ 3/1
+ ---
+variables.c
+ - make sure that the return value from find_variable is non-null
+ before trying to use it in chkexport. Fixes bug reported by
+ Evangelos Foutras <foutrelis@gmail.com>
+
+ 3/3
+ ---
+parse.y
+ - when adding $$ to the current token buffer in read_token_word(),
+ don't xmalloc a buffer for two characters and then strcpy it, just
+ copy the characters directly into the token buffer. Fix from
+ Michael Whitten <mfwitten@gmail.com>
+
+execute_cmd.c
+ - fix expand_word_unsplit to add the W_NOSPLIT2 flag to the word to
+ be expanded, so "" doesn't add CTLNUL. Similar to fix of 2/18 to
+ expand_string_for_rhs. Fixes bug reported by Nathanael D. Noblet
+ <nathanael@gnat.ca> and Matthias Klose <doko@debian.org>
+
+parse.y
+ - fix extended_glob case of read_token_word to allocate an extra
+ space in the buffer for the next character read after the extended
+ glob specification if it's a CTLESC or CTLNUL. Report and fix from
+ Michael Witten <mfwitten@gmail.com>
+ - fix shell expansions case of read_token_word to allocate an extra
+ space in the buffer for the next character read after the shell
+ expansion if it's a CTLESC or CTLNUL. Report and fix from
+ Michael Witten <mfwitten@gmail.com>
+ - TENTATIVE: fix read_token_word to reduce the amount of buffer space
+ required to hold the translated and double-quoted value of $"..."
+ strings. Report and fix from Michael Witten <mfwitten@gmail.com>
+ - change code around got_character and got_escaped_character labels to
+ make sure that we call RESIZE_MALLOCED_BUFFER before adding the
+ CTLESC before a CTLESC or CTLNUL, and before adding the character if
+ we're not adding a CTLESC. Report and fix from
+ Michael Witten <mfwitten@gmail.com>
+
+subst.c
+ - new param flags value, PF_ASSIGNRHS, mirrors W_ASSIGNRHS, noting that
+ parameter expansion is on rhs of assignment statement. That inhibits
+ word splitting
+ - change param_expand to call string_list_dollar_at with quoted == 1
+ if PF_ASSIGNRHS is set, so it will quote IFS characters in the
+ positional parameter before separating them with the first char of
+ $IFS. This keeps the rhs from being split inappropriately. Fixes
+ bug reported by Andres Perera <andres.p@zoho.com>
+
+ 3/4
+ ---
+lib/readline/bind.c
+ - add a missing free of `names' in rl_function_dumper. Bug report
+ and fix from Michael Snyder <msnyder@vmware.com>
+
+ 3/5
+ ---
+lib/readline/rltty.c
+ - change rl_deprep_terminal so it uses fileno (stdin) for the tty fd
+ if rl_instream is not set, like rl_prep_terminal
+
+ 3/6
+ ---
+lib/readline/display.c
+ - fix rl_message to use a dynamically-allocated buffer instead of a
+ fixed-size buffer of 128 chars for the `local message prompt'. Bug
+ report and fix from Micah Cowan <micah@cowan.name>
+
+ 3/7
+ ---
+jobs.c
+ - add sentinel to wait_sigint_handler so it only sets wait_sigint_received
+ if waiting_for_child is non-zero; otherwise, it restores the old
+ SIGINT handler and sends itself the SIGINT
+ - set waiting_for_child around the calls to waitchld that use it to
+ synchronously wait for a process
+ - change logic that decides whether or not the child process blocked
+ or handled SIGINT based on whether or not waitpid returns -1/EINTR
+ and the shell receives a SIGINT and the child does not exit. If
+ the child later exits due to SIGINT, cancel the assumoption that it
+ was handled
+ - instead of testing whether or not the child exited due to SIGINT
+ when deciding whether the shell should act on a SIGINT it received
+ while waiting, test whether or not we think the child caught
+ SIGINT. If it did, we let it go (unless the shell has it trapped);
+ if it did not catch it, the shell acts on the SIGINT. Fix from
+ Linus Torvalds <torvalds@linux-foundation.org>, bug report originally
+ from Oleg Nesterov <oleg@redhat.com>
+
+ 3/8
+ ---
+shell.c
+ - initialize no_line_editing to 1 if READLINE is not defined -- we
+ can't have line editing without readline
+
+ 3/12
+ ----
+lib/readline/signals.c
+ - add SIGHUP to the set of signals readline handles
+
+lib/readline/doc/rltech.texi
+ - document that SIGHUP is now part of the set of signals readline
+ handles
+
+lib/readline/input.c
+ - if _rl_caught_signal indicates that read() was interrupted by a
+ SIGHUP or SIGTERM, return READERR or EOF as appropriate
+ - call rl_event_hook, if it's set, if call to read in rl_getc
+ returns -1/EINTR. If rl_event_hook doesn't do anything, this
+ continues the loop as before. This handles the other fatal
+ signals
+
+execute_cmd.c
+ - add a couple of QUIT; calls to execute_disk_command and
+ execute_simple_command to improve responsiveness to interrupts
+ and fatal signals
+
+input.c
+ - rearrange getc_with_restart so that the return values from read()
+ are handled right
+
+parse.y
+ - don't need to set terminate_immediately in yy_stream_get, since
+ getc_with_restart checks for terminating signals itself
+ - since readline returns READERR on SIGHUP or SIGTERM, don't need
+ to set terminate_immediately. Still doesn't handle other
+ signals well -- will have to check that some more
+
+bashline.c
+ - new function, bash_event_hook, for rl_event_hook. Just checks for
+ terminating signals and acts on them using CHECK_TERMSIG.
+ - set rl_event_hook to bash_event_hook
+
+builtins/read.def
+ - take out setting terminate_immediately; add calls to CHECK_TERMSIG
+ after read calls
+
+doc/{bash.1,bashref.texi}
+ - move the text describing the effect of negative subscripts used to
+ reference indexed array elements to the paragraphs describing
+ ${parameter[subscript]}, since that's where they are implemented.
+ Pointed out by Christopher F. A. Johnson <cfajohnson@gmail.com>
+
+arrayfunc.[ch],subst.c
+ - array_expand_index now takes a new first argument: a SHELL_VAR *
+ of the array variable being subscripted. Can be used later to fully
+ implement negative subscripts
+
+ 3/14
+ ----
+lib/glob/glob.c
+ - fix mbskipname to not turn the directory entry name into a wide char
+ string if the conversion of the pattern to a wide char string fails
+ - fix mbskipname to call skipname if either the pattern or the filename
+ can't be converted into a wide-char string
+
+lib/glob/xmbsrtowcs.c
+ - fix xdupmbstowcs2 to handle return value of 0 from mbsnrtowcs and
+ short-circuit with failure in that case. Fixes bug reported by
+ Roman Rakus <rrakus@redhat.com>
+
+ 3/15
+ ----
+bashline.c
+ - new variable, bash_filename_quote_characters to store the value
+ assigned to rl_filename_quote_characters so it can be restored
+ if changed.
+ - change bashline_reset and attempt_shell_completion to restore
+ rl_filename_quote_characters if not set to default
+
+ 3/22
+ ----
+lib/glob/glob.c
+ - wdequote_pathname falls back to udequote_pathname if xdupmbstowcs
+ fails to convert the pathname to a wide-character string
+
+lib/glob/xmbsrtowcs.c
+ - xdupmbstowcs2: change to fix problem with leading '\\' (results in
+ nms == 0, which causes it to short-circuit with failure right
+ away). Fixes bug pointed out by Werner Fink <werner@suse.de>
+ - xdupmbstowcs2: compensate for mbsnrtowcs returning 0 by taking the
+ next single-byte character and going on
+ - xdupmbstowcs2: change memory allocation to increase by WSBUF_INC
+ bytes; try to avoid calls to realloc (even if they don't actually
+ result in more memory being allocated)
+
+ 3/24
+ ----
+doc/{bash.1,bashref.texi}
+ - slightly modify BASH_SUBSHELL description based on complaint from
+ Sam Liddicott <sam@liddicott.com>
+
+ 3/25
+ ----
+trap.c
+ - change free_trap_strings to not call free_trap_string for signals
+ that are being ignored, like reset_or_restore_signal_handlers.
+ Fixes bug reported by Satoshi Takahashi <blue3waters@gmail.com>
+
+ 3/26
+ ----
+lib/readline/rltypedefs.h
+ - remove old Function/VFunction/CPFunction/CPPFunction typedefs as
+ suggested by Tom Tromey <tromey@redhat.com>
+
+lib/readline/rlstdc.h
+ - move defines for USE_VARARGS/PREFER_STDARG/PREFER_VARARGS from
+ config.h.in to here because declaration of rl_message in
+ readline.h uses the defines. This makes it hard for another packages
+ to use after the header files are installed, since config.h is not
+ one of the installed files. Suggested by Tom Tromey
+ <tromey@redhat.com>
+
+ 3/27
+ ----
+print_cmd.c
+ - change indirection_string from a static buffer to a dynamic one
+ managed by indirection_level_string(), so we don't end up truncating
+ PS4. Suggested by Dennis Williamson <dennistwilliamson@gmail.com>
+
+lib/readline/shell.c
+ - change sh_set_lines_and_columns to use static buffers instead of
+ allocating the buffers to pass to setenv/putenv
+
+lib/readline/terminal.c
+ - change _rl_get_screen_size to not call sh_set_lines_and_columns if
+ ignore_env == 0
+ - _rl_sigwinch_resize_terminal: new function to just retrieve terminal
+ size, ignoring environment
+
+lib/readline/rlprivate.h
+ - new external declaration for _rl_sigwinch_resize_terminal() (currently
+ unused)
+
+lib/readline/signals.c
+ - rl_sigwinch_handler: set _rl_caught_signal to SIGWINCH
+ - rl_sigwinch_handler: don't immediately call rl_resize_terminal; just
+ leave _rl_caught_signal set for RL_CHECK_SIGNALS to handle
+ - _rl_signal_handler: call rl_resize_terminal if sig == SIGWINCH.
+ Should fix hang when sending multiple repeated SIGWINCH reported by
+ Henning Bekel <h.bekel@googlemail.com>
+
+ 3/29
+ ----
+lib/sh/snprintf.c
+ - include math.h for any defines for isinf/isnan
+ - use code from gnulib documentation to implement isinf/isnan if they
+ are not defined
+
+configure.in
+ - don't check for isinf or isnan; c99 says they're macros anyway
+
+config.h.in
+ - remove defines for ISINF_IN_LIBC and ISNAN_IN_LIBC, no longer used
+ by snprintf.c
+
+ 4/2
+ ---
+braces.c
+ - brace_gobbler: fix to understand double-quoted command substitution,
+ since the shell understands unquoted comsubs. Fixes bug reported
+ by Michael Whitten <mfwitten@gmail.com>
+
+lib/readline/display.c
+ - include <pc.h> on MDOS
+ - get and set screen size using DJGPP-specific calls on MSDOS
+ - move cursor up clear screen using DJGPP-specific calls
+ - don't call tputs on DJGPP; there is no good terminfo support
+
+lib/readline/terminal.c
+ - include <pc.h> on MDOS
+ - get and set screen size using DJGPP-specific calls on MSDOS
+ - use DJGPP-specific initialization on MSDOS, zeroing all the
+ _rl_term_* variables
+ - don't call tputs on DJGPP; there is no good terminfo support
+ DJGPP support from Eli Zaretskii <eliz@gnu.org>
+
+ 4/6
+ ---
+
+config-top.h
+ - change DEFAULT_PATH_VALUE to something more useful and modern
+
+ 4/8
+ ---
+tests/printf2.sub
+ - make sure LC_ALL and LC_CTYPE are set so LANG assignment takes effect.
+ Reported by Cedric Arbogast <arbogast.cedric@gmail.com>
+
+ 4/11
+ ----
+include/chartypes.h
+ - fix a couple of dicey defines (though ones that don't cause any
+ compiler warnings) in IN_CTYPE_DOMAIN
+
+doc/{bashref.texi,bash.1}
+ - add note referring to duplicating file descriptors in sections
+ describing redirecting stdout and stderr and appending to stdout
+ and stderr. Suggested by Matthew Dinger <mdinger.bugzilla@gmail.com>
+
+pcomplete.c
+ - it_init_helptopics: new function to support completing on help topics,
+ not just builtins
+ - it_helptopics: new programmable completion list of help topics
+ - build list of helptopic completions in gen_action_completions on
+ demand
+
+pcomplete.h
+ - new extern declaration for it_helptopics
+
+builtins/complete.def
+ - the `helptopic' action now maps to CA_HELPTOPIC intead of CA_BUILTIN,
+ since there are more help topics than just builtins. Suggested by
+ Clark Wang <dearvoid@gmail.com>
+
+ 4/12
+ ----
+print_cmd.c
+ - fix print_arith_for_command to add a call to PRINT_DEFERRED_HEREDOCS
+ before ending the body of the command, so heredocs get attached to
+ the right command instead of to the loop. From gentoo bug 363371
+ http://bugs.gentoo.org/show_bug.cgi?id=363371
+
+execute_cmd.c
+ - change coproc_pidchk to unset the appropriate shell variables when
+ the (currently single) known coproc pid terminates
+ - cleanup and new functions to fully support multiple coprocesses when
+ and if I decide to go there
+
+ 4/13
+ ----
+print_cmd.c
+ - fix print_group_command to add a call to PRINT_DEFERRED_HEREDOCS
+ after call to make_command_string_internal before printing closing
+ `}'
+ - fix make_command_string_internal to add a call to
+ PRINT_DEFERRED_HEREDOCS after recursive call to
+ make_command_string_internal in case cm_subshell before printing
+ closing `)'
+
+ 4/14
+ ----
+print_cmd.c
+ - change overlapping strcpy in named_function_string to memmove
+
+sig.h
+ - UNBLOCK_SIGNAL: convenience define, same as UNBLOCK_CHILD, just
+ restores an old signal mask
+
+trap.c
+ - set_signal: instead of setting the signal handler to SIG_IGN while
+ installing the new trap handler, block the signal and unblock it
+ after the new handler is installed. Fixes bug reported by Roman
+ Rakus <rrakus@redhat.com>
+
+ 4/15
+ ----
+doc/{bash.1,bashref.texi}
+ - make it clear that enabling monitor mode means that all jobs run in
+ separate process groups
+
+ 4/18
+ ----
+builtins/fc.def
+ - update fix of 4/15/2010 to not take saved_command_line_count into
+ account when stepping down the history list to make sure that
+ last_hist indexes something that is valid. Fixes bug reported by
+ <piuma@piumalab.org>
+
+ 4/19
+ ----
+builtins/fc.def
+ - fc_gethnum: make sure the calculation to decide the last history
+ entry is exactly the same as fc_builtin. Fixes bug uncovered by
+ fix of 4/18 to stop seg fault
+
+ 4/22
+ ----
+lib/readline/terminal.c
+ - change _rl_enable_meta_key to set a flag indicating that it sent the
+ enable-meta sequence
+ - _rl_disable_meta_key: new function to turn off meta mode after we
+ turned it on with _rl_enable_meta_key
+
+lib/readline/rlprivate.h
+ - extern declaration for _rl_disable_meta_key
+
+configure.in
+ - if not cross-compiling, set CFLAGS_FOR_BUILD from any CFLAGS inherited
+ from the environment. Fixes HP/UX build problem reported by
+ "Daniel Richard G." <skunk@iSKUNK.ORG>
+
+ 4/26
+ ----
+config-top.h
+ - define MULTIPLE_COPROCS to 0 so the code is still disabled but easy
+ to enable via configure option or editing this file
+
+ 4/29
+ ----
+lib/sh/eaccess.c
+ - freebsd provides faccessat, with the same misfeature as their eaccess
+ and access implementations (X_OK returns true for uid==0 regardless
+ of the actual file permissions), so reorganize code to check the
+ file permissions as with eaccess. Report and fix from Johan Hattne
+ <johan.hattne@utsouthwestern.edu>
+
+ 5/2
+ ---
+doc/{bash.1,bashref.texi}
+ - add forward reference to `Pattern Matching' from `Pathname
+ Expansion', suggested by Greg Wooledge <wooledg@eeg.ccf.org>
+
+ 5/5
+ ---
+pcomplib.c
+ - the bash_completion project now distributes over 200 completions
+ for various programs, with no end in sight, so increase the value
+ of COMPLETE_HASH_BUCKETS from 32 to 128
+
+pathexp.c
+ - quote_string_for_globbing: make sure CTLESC quoting CTLESC is
+ translated into \<CTLESC> even if the flags include QGLOB_REGEXP.
+ We don't want to process the second CTLESC as a quote character.
+ Fixes bug reported by Shawn Bohrer <sbohrer@rgmadvisors.com>
+
+ 5/6
+ ---
+builtins/printf.def
+ - change PRETURN to not call fflush if ferror(stdout) is true
+ - if a call to one of the stdio functions or printstr leaves
+ ferror(stdout) true, and PRETURN is going to be called, let PRETURN
+ print the error message rather than doubling up the messages. Fixes
+ problem reported by Roman Rakus <rrakus@redhat.com>
+
+ 5/9
+ ---
+doc/{bash.1,bashref.texi}
+ - add note to the effect that lists inside compound command can be
+ terminated by newlines as well as semicolons. Suggested by
+ Roman Byshko <rbyshko@gmail.com>
+
+ 5/10
+ ----
+subst.c
+ - remove_quoted_nulls: fix problem that caused it to skip over the
+ character after a CTLNUL, which had the effect of skipping every
+ other of a series of CTLNULs. Fixes bug reported by
+ Marten Wikstrom <marten.wikstrom@keystream.se>
+
+ 5/11
+ ----
+subst.c
+ - extract_process_subst: add SX_COMMAND flag to call to
+ extract_delimited_string, since we're expanding the same sort of
+ command as command substitution. Fixes bug reported in Ubuntu
+ bug 779848
+
+ 5/12
+ ----
+configure.in
+ - set the prefer_shared and prefer_static variables appropriately
+ depending on the value of $opt_static_link
+
+aclocal.m4
+ - AC_LIB_LINKFLAGS_BODY: change to not prefer shared versions of the
+ libraries it's searching for if the prefer_shared variable is "no".
+ Fixes problem reported by Cedric Arbogast <arbogast.cedric@gmail.com>
+
+ 5/13
+ ----
+lib/readline/readline.c
+ - _rl_internal_teardown: add call to _rl_disable_meta_key to make the
+ meta key active only for the duration of the call to readline()
+ - _rl_internal_setup: move call to _rl_enable_meta_key here from
+ readline_initialize_everything so the meta key is active only for
+ the duration of the call to readline(). Suggestion from Miroslav
+ Lichvar <mlichvar@redhat.com>
+
+builtins/help.def
+ - help_builtin: change strncmp to strcmp so that `help read' no longer
+ matches `readonly'. Suggested by Clark Wang <dearvoid@gmail.com>
+
+config.h.in
+ - add define for GLIBC21, checked using jm_GLIBC21 as part of the tests
+ for libintl
+
+lib/malloc/malloc.c
+ - internal_free: don't use the cached value of memtop when deciding
+ whether or not to adjust the break and give memory back to the kernel
+ when using the GNU C library, since glibc uses sbrk for its own
+ internal purposes. From Debian bug 614815, reported by Samuel
+ Thibault <samuel.thibault@gnu.org>
+
+aclocal.m4
+ - BASH_STRUCT_WEXITSTATUS_OFFSET: change AC_RUN_IFELSE to AC_TRY_RUN
+ to avoid warning about not using AC_LANG_SOURCE
+
+ 5/14
+ ----
+bashline.[ch]
+ - two new functions, bashline_set_event_hook and bashline_reset_event_hook,
+ to set rl_event_hook to bash_event_hook and back to NULL, respectively
+ - don't set rl_event_hook unconditionally
+
+sig.c
+ - termsig_sighandler: if the shell is currently interactive and
+ readline is active, call bashline_set_event_hook to cause
+ termsig_handler to be called via bash_event_hook when the shell
+ returns from the signal handler
+
+ 5/15
+ ----
+lib/readline/display.c
+ - _rl_col_width: Mac OS X has a bug in wcwidth: it does not return 0
+ for UTF-8 combining characters. Added workaround dependent on
+ MACOSX. Fixes problem pointed out by Thomas De Contes
+ <d.l.tDecontes@free.fr>
+
+ 5/16
+ ----
+lib/readline/rlmbutil.h
+ - WCWIDTH: wrapper for wcwidth that returns 0 for Unicode combining
+ characters on systems where wcwidth is broken (e.g., Mac OS X).
+
+lib/readline/{complete,display,mbutil}.c
+ - use WCWIDTH instead of wcwidth
+
+ 5/17
+ ----
+lib/readline/display.c
+ - update_line: after computing ofd and nfd, see whether the next
+ character in ofd is a zero-width combining character. If it is,
+ back ofd and nfd up one, so the base characters no longer compare
+ as equivalent. Fixes problem reported by Keith Winstein
+ <keithw@mit.edu>
+
+lib/readline/nls.c
+ - _rl_utf8locale: new flag variable, set to non-zero if the current
+ locale is UTF-8
+ - utf8locale(): new function, returns 1 if the passed lspec (or the
+ current locale) indicates that the locale is UTF-8. Called from
+ _rl_init_eightbit
+
+lib/readline/rlprivate.h
+ - extern declaration for _rl_utf8locale
+
+locale.c
+ - locale_utf8locale: new flag variable, set to non-zero if the current
+ locale is UTF-8 (currently unused)
+ - locale_isutf8(): new function, returns 1 if the passed lspec (or the
+ current locale) indicates that the locale is UTF-8. Should be called
+ whenever the locale or LC_CTYPE value is modified
+
+aclocal.m4
+ - BASH_WCWIDTH_BROKEN: new test for whether or not wcwidth returns
+ zero-width characters like unicode combining characters as having
+ display length 1; define WCWIDTH_BROKEN in this case
+
+config.h.in
+ - WCWIDTH_BROKEN: new define
+
+lib/readline/rlmbutil.h
+ - change WCWIDTH macro to use _rl_utf8locale and the full range of
+ Unicode combining characters (U+0300-U+036F)
+
+ 5/19
+ ----
+lib/readline/rlprivate.h
+ - _rl_search_context: new member, prevc, will hold character read
+ prior to lastc
+
+lib/readline/isearch.c
+ - _rl_isearch_dispatch: if the character causes us to index into
+ another keymap, save that character in cxt->prevc
+ - _rl_isearch_dispatch: if we index into another keymap, but don't
+ find a function that's special to i-search, and the character that
+ caused us to index into that keymap would have terminated the
+ search, push back cxt->prevc and cxt->lastc to make it appear as
+ if `prevc' terminated the search, and execute lastc as a command.
+ We have to push prevc back so we index into the same keymap before
+ we read lastc. Fixes bug report from Davor Cubranic
+ <cubranic@stat.ubc.ca>
+
+ 5/20
+ ----
+expr.c
+ - expr_bind_variable: pay attention to the return value from
+ bind_variable and check whether or not we should error out due to
+ a readonly or noassign variable. Fixes bug reported by Eric
+ Blake <eblake@redhat.com>
+
+ 5/26
+ ----
+
+lib/readline/search.c
+ - include histlib.h for ANCHORED_SEARCH defines
+ - rl_history_search_flags: new variable, holds ANCHORED_SEARCH flag for
+ the duration of a history search
+ - rl_history_search_reinit: takes a new flags variable, defines whether
+ or not the search is anchored; assigned to rl_history_search_flags
+ - rl_history_serarch_reinit: if ANCHORED_SEARCH flag passed, add ^ to
+ beginning of search string; otherwise search string is unmodified
+ - rl_history_search_internal: set rl_point appropriately based on
+ whether or not rl_history_search_flags includes ANCHORED_SEARCH
+ - rl_history_substr_search_forward: new function, for non-anchored
+ substring search forward through history for string of characters
+ preceding rl_point
+ - rl_history_substr_search_backward: new function, for non-anchored
+ substring search backward through history for string of characters
+ preceding rl_point. Original code from Niraj Kulkarni
+ <kulkarniniraj14@gmail.com>
+
+lib/readline/readline.h
+ - extern declarations for rl_history_substr_search_{for,back}ward
+
+lib/readline/funmap.c
+ - history-substring-search-forward: new bindable command, invokes
+ rl_history_substr_search_forward
+ - history-substring-search-backward: new bindable command, invokes
+ rl_history_substr_search_backward
+
+lib/readline/doc/{rluser.texi,readline.3}
+ - document history-substring-search-forward and
+ history-substring-search-backward
+
+ 5/27
+ ----
+{nojobs,jobs}.c
+ - add support for DONT_REPORT_SIGTERM so that the shell doesn't print
+ a message when a job exits due to SIGTERM since that's the default
+ signal sent by the kill builtin. Suggested by Marc Herbert
+ <mark.herbert@gmail.com>
+
+config-top.h
+ - DONT_REPORT_SIGTERM: new user-modifiable setting. Commented out
+ by default
+
+ 5/28
+ ----
+lib/readline/bind.c
+ - _rl_skip_to_delim: skip to a closing double quote or other delimiter,
+ allowing backslash to quote any character, including the delimiter
+ - rl_parse_and_bind: call _rl_skip_to_delim instead of using inline
+ code
+ - rl_parse_and_bind: allow quoted strings as the values of string
+ variables. Variable values without double quotes have trailing
+ whitespace removed (which still allows embedded whitespace, for
+ better or worse). Fixes problem with string variables not matching
+ in `set' command if values happen to have trailing spaces or tabs
+ (debian bash bug #602762), but introduces slight incompatibility.
+
+ 5/29
+ ----
+doc/{bash.1,bashref.texi}
+ - clarify unset description to specify that without options, a
+ variable, then a shell function if there is no variable by that
+ name, is unset. Fixes discrepancy reported by Mu Qiao
+ <qiaomuf@gentoo.org>
+
+ 6/4
+ ----
+doc/{bash.1,bashref.texi}
+ - clarify description of LINES and COLUMNS (and checkwinsize shopt
+ option) to make it clear that only interactive shells set a
+ handler for SIGWINCH and update LINES and COLUMNS. Original
+ report submitted by Jonathan Nieder <jrnieder@gmail.com>
+
+arrayfunc.c
+ - expand_compound_array_assignment: defer expansion of words between
+ parens when performing compound assignmnt to an associative array
+ variable
+ - assign_compound_array_list: perform the same expansions when doing
+ a compound array assignment to an associative array variable as
+ when doing a straight array index assignment. The idea is that
+ foo=( [ind1]=bar [ind2]=quux)
+ is the same as
+ foo[ind1]=bar ; foo[ind2]=quux
+
+ This fixes problems with double-expansion and quote removal being
+ performed on the array indices
+
+ 6/13
+ ----
+doc/{bash.1,bashref.texi}
+ - Add a little text to make it clear that the locale determines how
+ range expressions in glob patterns are handled.
+
+
+ 6/21
+ ----
+builtins/read.def
+ - display a message and return error status if -a is used with an
+ existing associative array. Fixes bug reported by Curtis Doty
+ <curtis@greenkey.net>
+
+ 6/24
+ ----
+{jobs,nojobs}.c
+ - non-interactive shells now react to the setting of checkwinsize
+ and set LINES and COLUMNS after a foreground job exits. From a
+ suggestion by Leslie Rhorer <lrhorer@satx.rr.com>
+
+doc/{bash.1,bashref.texi}
+ - checkwinsize: remove language saying that only interactive shells
+ check the window size after each command
+
+lib/readline/histfile.c
+ - history_backupfile: new file, creates a backup history file name
+ given a filename (appending `-')
+ - history_do_write: when overwriting the history file, back it up
+ before writing. Restore backup file on a write error. Suggested
+ by chkno@chkno.net
+
+bashline.c
+ - find_cmd_name: two new arguments, return the start and end of the
+ actual text string used to find the command name, without taking
+ whitespace into account
+ - attempt_shell_completion: small changes to make sure that completion
+ attempted at the beginning of a non-empty line does not find a
+ programmable completion, even if the command name starts at point
+ - attempt_shell_completion: small change to make sure that completion
+ does not find a progcomp when in whitespace before the command
+ name
+ - attempt_shell_completion: small change to make sure that completion
+ does not find a progcomp when point is at the first character of a
+ command name, even when there is leading whitespace (similar to
+ above). Fixes problems noted by Ville Skytta <ville.skytta@iki.fi>
+
+subst.c
+ - brace_expand_word_list: since the individual strings in the strvec
+ returned by brace_expand are already allocated, don't copy them to
+ newly-allocated memory when building the WORD_LIST, just use them
+ intact
+
+locale.c
+ - locale_mb_cur_max: cache value of MB_CUR_MAX when we set or change
+ the locale to avoid a function call every time we need to read it
+
+shell.h
+ - new struct to save shell_input_line and associated variables:
+ shell_input_line_state_t
+ - add members of sh_parser_state_t to save and restore token and the
+ size of the token buffer
+
+parse.y
+ - {save,restore}_input_line_state: new functions to save and restore
+ shell_input_line and associated variables
+ - {save,restore}_parser_state: add code to save and restore the token
+ and token buffer size
+ - xparse_dolparen: call save_ and restore_input_line_state to avoid
+ problems with overwriting shell_input_line when we recursively
+ call the parser to parse a command substitution. Fixes bug
+ reported by Rui Santos <rsantos@grupopie.com>
+
+include/shmbutil.h
+ - use locale_mb_cur_max instead of MB_CUR_MAX in ADVANCE_CHAR and
+ similar macros
+
+lib/glob/smatch.c
+ - rangecmp,rangecmp_wc: change to take an additional argument, which
+ forces the use of strcoll/wscoll when non-zero. If it's 0, a new
+ variable `glob_asciirange' controls whether or not we use strcoll/
+ wscoll. If glob_asciirange is non-zero, we use straight
+ C-locale-like ordering. Suggested by Aharon Robbins
+ <arnold@skeeve.com>
+
+ 6/30
+ ----
+execute_cmd.c
+ - execute_pipeline: make sure the lastpipe code is protected by
+ #ifdef JOB_CONTROL. Fixes problem reported by Thomas Cort
+ <tcort@minix3.org>
+
+ 7/2
+ ---
+lib/readline/complete.c
+ - EXPERIMENTAL: remove setting of _rl_interrupt_immediately around
+ completion functions that touch the file system. Idea from Jan
+ Kratochvil <jan.ktratochvil@redhat.com> and the GDB development
+ team
+
+lib/readline/signals.c
+ - rl_signal_handler: if we're in callback mode, don't interrupt
+ immediately on a SIGWINCH
+
+ 7/3
+ ---
+bashline.c
+ - set_directory_hook: and its siblings are a new set of functions to
+ set, save, and restore the appropriate directory completion hook
+ - change callers to use {set,save,restore}_directory_hook instead of
+ manipulating rl_directory_rewrite_hook directly
+ - dircomplete_expand: new variable, defaults to 0, if non-zero causes
+ directory names to be word-expanded during word and filename
+ completion
+ - change {set,save,restore}_directory_hook to look at dircomplete_expand
+ and change rl_directory_completion_hook or rl_directory_rewrite_hook
+ appropriately
+
+bashline.h
+ - extern declaration for set_directory_hook so shopt code can use it
+
+ 7/6
+ ---
+builtins/shopt.def
+ - globasciiranges: new settable shopt option, makes glob ranges act
+ as if in the C locale (so b no longer comes between A and B).
+ Suggested by Aharon Robbins <arnold@skeeve.com>
+
+ 7/7
+ ---
+doc/{bash.1,bashref.texi}
+ - document new `globasciiranges' shopt option
+
+ 7/8
+ ---
+builtins/shopt.def
+ - direxpand: new settable option, makes filename completion expand
+ variables in directory names like bash-4.1 did.
+ - shopt_set_complete_direxpand: new function, does the work for the
+ above by calling set_directory_hook
+
+doc/{bash.1,bashref.texi}
+ - document new `direxpand' shopt option
+
+ 7/15
+ ----
+lib/readline/isearch.c
+ - _rl_isearch_dispatch: when adding character to search string, use
+ cxt->lastc (which we use in the switch statement) instead of c,
+ since lastc can be modified earlier in the function
+
+ 7/18
+ ----
+lib/readline/rlprivate.h
+ - _rl_search_context: add another member to save previous value of
+ (multibyte) lastc: pmb is to mb as prevc is to lastc
+
+lib/readline/isearch.c:
+ - _rl_isearch_dispatch: if a key sequence indexes into a new keymap,
+ but doesn't find any bound function (k[ind].function == 0) or is
+ bound to self-insert (k[ind].function == rl_insert), back up and
+ insert the previous character (the one that caused the index into a
+ new keymap) and arrange things so the current character is the next
+ one read, so both of them end up in the search string. Fixes bug
+ reported by Clark Wang <dearvoid@gmail.com>
+ - _rl_isearch_dispatch: a couple of efficiency improvements when adding
+ characters to the isearch string
+
+ 7/24
+ ----
+lib/readline/isearch.c
+ - _rl_isearch_dispatch: save and restore cxt->mb and cxt->pmb
+ appropriately when in a multibyte locale
+
+doc/{bash.1,bashref.texi}
+ - correct description of {x}>file (and other redirection operators
+ that allocate a file descriptor) to note the the fd range is
+ greater than or equal to 10. Fixes problem reported by
+ Christian Ullrich
+
+lib/readline/signals.c
+ - rl_signal_handler: don't interrupt immediately if in callback mode
+
+lib/readline/callback.c
+ - rl_callback_read_char: install signal handlers only when readline
+ has control in callback mode, so readline's signal handlers aren't
+ called when the application is active (e.g., between the calls to
+ rl_callback_handler_install and rl_callback_read_char). If the
+ readline signal handlers only set a flag, which the application
+ doesn't know about, the signals will effectively be ignored until
+ the next time the application calls into the readline callback
+ interface. Fixes problem of calling unsafe functions from signal
+ handlers when in callback mode reported by Jan Kratochvil
+ <jan.kratochvil@redhat.com>
+
+execute_cmd.c
+ - fix_assignment_words: when in Posix mode, the `command' builtin
+ doesn't change whether or not the command name it protects is an
+ assignment builtin. One or more instances of `command'
+ preceding `export', for instance, doesn't make `export' treat its
+ assignment statement arguments differently. Posix interpretation
+ #351
+
+doc/{bash.1,bashref.texi}
+ - document new Posix-mode behavior of `command' when preceding builtins
+ that take assignment statements as arguments
+
+builtins/printf.def
+ - printstr: if fieldwidth or precision are < 0 or > INT_MAX when
+ supplied explicitly (since we take care of the `-' separately),
+ clamp at INT_MAX like when using getint(). Fixes issue reported
+ by Ralph Coredroy <ralph@inputplus.co.uk>
+
+ 7/25
+ ----
+lib/readline/chardefs.h
+ - isxdigit: don't define if compiling with c++; declared as a c++
+ template function. Fixes bug reported by Miroslav Lichvar
+ <mlichvar@redhat.com>
+
+builtins/printf.def
+ - getint: if garglist == 0, return whatever getintmax returns (0).
+ Fixes bug reported by Ralph Coredroy <ralph@inputplus.co.uk>
+
+ 7/28
+ ----
+doc/{bash.1,bashref.texi}
+ - minor changes to the descriptions of the cd and pushd builtins
+
+lib/sh/zread.c
+ - zsyncfd: change variable holding return value from lseek to
+ off_t. Bug report and fix from Gregory Margo <gmargo@pacbell.net>
+
+ 8/1
+ ---
+expr.c
+ - don't check for division by 0 when in a context where no evaluation
+ is taking place. Fixes bug reported by dnade.ext@orange-ftgroup.com
+
+ 8/6
+ ---
+execute_cmd.c
+ - execute_command_internal: the parent branch of the subshell code
+ (where the child calls execute_in_subshell) should not close all
+ open FIFOs with unlink_fifo_list if it's part of a shell function
+ that's still executing. Fixes bug reported by Maarten Billemont
+ <lhunath@lyndir.com>
+
+ 8/9
+ ---
+builtins/common.c
+ - get_exitstat: return EX_BADUSAGE (2) on a non-numeric argument
+
+builtins/return.def
+ - return_builtin: just call get_exitstat to get the return status,
+ let it handle proper parsing and handling of arguments. Fixes
+ issue most recently raised by Linda Walsh <bash@tlinx.org>.
+ Reverses change from 9/11/2008 (see above)
+
+ 8/16
+ ----
+doc/{bash.1,bashref.texi}
+ - clean up `set -e' language to make it clearer that any failure of
+ a compound command will cause the shell to exit, not just subshells
+ and brace commands
+
+ 8/17
+ ----
+configure.in
+ - make the various XXX_FOR_BUILD variables `precious' to autoconf to
+ avoid stale data
+ - change how CC_FOR_BUILD is initialized when cross-compiling and not,
+ but do not change behavior
+ - initialize CFLAGS_FOR_BUILD to -g when cross-compiling
+ - initialize LIBS_FOR_BUILD to $(LIBS) when not cross-compiling, empty
+ when cross-compiling
+ - create AUTO_CFLAGS variable to hold basic CFLAGS defaults; used when
+ CFLAGS not inherited from environment (like effect of old
+ auto_cflags variable)
+ - substitute LIBS_FOR_BUILD into output Makefiles
+ [changes inspired by bug report from Nathan Phillip Brink
+ <ohnobinki@ohnopublishing.net> -- gentoo bug 378941]
+
+builtins/Makefile.in
+ - substitute LIBS_FOR_BUILD from configure, not strictly initialized
+ to $(LIBS)
+
+ 8/27
+ ----
+doc/{bash.1,bashref.texi}
+ - minor changes to the here string description to clarify the
+ expansions performed on the word
+
+support/shobj-conf
+ - handle compilation on Lion (Mac OS X 10.7/darwin11) with changes
+ to darwin stanzas. Fixes readline bug reported by Vincent
+ Sheffer <vince.sheffer@apisphere.com>
+
+lib/sh/strtrans.c
+ - ansic_wshouldquote: check a string with multi-byte characters for
+ characters that needs to be backslash-octal escaped for $'...'
+ - ansic_shouldquote: if is_basic fails for one character, let
+ ansic_wshouldquote examine the rest of the string and return what
+ it returns. From a patch sent by Roman Rakus <rrakus@redhat.com>
+
+ 8/30
+ ----
+lib/sh/strtrans.c
+ - ansic_quote: changes to quote (or not) multibyte characters. New
+ code converts them to wide characters and uses iswprint to check
+ valid wide chars. From a patch sent by Roman Rakus
+ <rrakus@redhat.com>
+
+ 9/7
+ ---
+lib/sh/shquote.c
+ - sh_backslash_quote: change to be table-driven so we can use a
+ different table if we want to
+ - sh_backslash_quote: takes a second char table[256] argument;
+
+externs.h
+ - sh_backslash_quote: add second argument to function prototype
+
+bashline.c,braces.c,parse.y,builtins/printf.def
+ - change callers of sh_backslash_quote to add second argument
+
+bashline.c
+ - filename_bstab: table of characters to pass to sh_backslash_quote;
+ characters with value 1 will be backslash-quoted
+ - set_filename_bstab: turn on characters in filename backslash-quote
+ table according to passed string argument
+ - call set_filename_bstab every time rl_filename_quote_characters is
+ assigned a value
+ - bash_quote_filename: call sh_backslash_quote with filename_bstab
+ as second argument. This allows other characters in filenames to
+ be quoted without quoting, for instance, a dollar sign in a shell
+ variable reference
+
+ 9/8
+ ---
+bashline.c
+ - complete_fullquote: new variable, controls table passed to
+ sh_backslash_quote. If non-zero (the default), the standard set
+ of shell metacharacters -- as in bash versions up to and including
+ bash-4.2 -- gets backslash-quoted by the completion code. If zero,
+ sh_backslash_quote gets the table with the characters in the
+ variable reference removed, which means they are removed from the
+ set of characters to be quoted in filenames
+
+ 9/10
+ ----
+bashline.c
+ - bash_filename_stat_hook: new function, designed to expand variable
+ references in filenames before readline passes them to stat(2)
+ to determine whether or not they are a directory
+
+ 9/15
+ ----
+builtins/declare.def
+ - if assign_array_element fails due to a bad (or empty) subscript, mark
+ it as an assignment error and don't attempt any further processing
+ of that declaration. Fixes segfault bug reported by Diego Augusto
+ Molina <diegoaugustomolina@gmail.com>
+
+ 9/19
+ ----
+expr.c
+ - exppower: replace the simple exponentiation algorithm with an
+ implementation of exponentiation by squaring. Inspired by report
+ from Nicolas ARGYROU <nargy@yahoo.com>
+
+bashline.c
+ - bash_quote_filename: check for rtext being non-null before
+ dereferencing it
+ - set_saved_history: operate_and_get_next assumes that the previous
+ line was added to the history, even when the history is stifled and
+ at the max number of entries. If it wasn't, make sure the history
+ number is incremented properly. Partial fix for bug reported by
+ gregrwm <backuppc-users@whitleymott.net>
+
+doc/{bash.1,bashref.texi},lib/readline/doc/{hsuser,rluser}.texi
+ - minor editorial changes inspired by suggestions from
+ Roger Zauner <rogerx.oss@gmail.com>
+
+ 9/20
+ ----
+lib/intl/localealias.c
+ - read_alias_file: close resource leak (fp) when returning on error
+
+ 9/22
+ ----
+execute_command.c
+ - execute_intern_function: implement Posix interpretation 383 by making
+ it an error to define a function with the same name as a special
+ builtin when in Posix mode.
+ http://austingroupbugs.net/view.php?id=383#c692
+
+ 9/25
+ ----
+doc/{bash.1,bashref.texi}
+ - formatting and some content changes from Benno Schulenberg
+ <bensberg@justemail.net>
+ - document new posix-mode behavior from interp 383 change of 9/22
+
+ 9/30
+ ----
+execute_cmd.c
+ - shell_execve: add strerror to error message about executable file
+ that shell can't execute as a shell script. From suggestion by
+ daysleeper <daysleeper@centrum.cz>
+
+ 10/1
+ ----
+bashhist.c
+ - maybe_add_history: act as if literal_history is set when parser_state
+ includes PST_HEREDOC, so we save the bodies of here-documents just
+ as they were entered. Fixes bug reported by Jonathan Wakely
+ <bugs@kayari.org>
+ - bash_add_history: make sure that the second and subsequent lines of
+ a here document don't have extra newlines or other delimiting
+ chars added, since they have the trailing newline preserved, when
+ `lithist' is set and history_delimiting_chars isn't called
+
+execute_cmd.c
+ - execute_command_internal: avoid fd exhaustion caused by using
+ process substitution in loops inside shell functions by using
+ copy_fifo_list and close_new_fifos (). Fixes debian bash bug
+ 642504
+
+lib/readline/complete.c
+ - new variable, rl_filename_stat_hook, used by append_to_match. If
+ filename completion is desired, and rl_filename_stat_hook points
+ to a function, call that function to expand the filename in an
+ application-specific way before calling stat.
+
+bashline.c
+ - bash_default_completion: if variable completion returns a single
+ match, use bash_filename_stat_hook and file_isdir to determine
+ whether or not the variable name expands to a directory. If it
+ does, set the filename_append_character to `/'. This is not
+ perfect, so we will see how it works out. Adds functionality
+ requested by Peter Toft <pto@linuxbog.dk> and Patrick Pfeifer
+ <patrick@pfeifer.de>
+ - rl_filename_stat_hook: assigned bash_filename_stat_hook, so things
+ like $HOME/Downloads (after completion) have a slash appended.
+ In general, this causes the stat hook to be called whenever
+ filename completion is appended. Adds functionality requested by
+ Patrick Pfeifer <patrick@pfeifer.de>
+
+lib/readline/readline.h
+ - new extern declaration for rl_filename_stat_hook
+
+lib/readline/doc/rltech.texi
+ - rl_directory_rewrite_hook: now documented
+ - rl_filename_stat_hook: document
+
+pcomplete.c
+ - gen_action_completions: in the CA_DIRECTORY case, turn off
+ rl_filename_completion_desired if it was off before we called
+ rl_filename_completion_function and we didn't get any matches.
+ Having it on causes readline to quote the matches as if they
+ were filenames. Adds functionality requested by many,
+ including Clark Wang <dearvoid@gmail.com>
+
+assoc.[ch]
+ - assoc_replace: new function, takes the same arguments as
+ assoc_insert, but returns the old data instead of freeing it
+ - assoc_insert: if the object returned by hash_insert doesn't have
+ the same value for its key as the key passed as an argument, we
+ are overwriting an existing value. In this case, we can free the
+ key. Fixes bug reported by David Parks <davidparks21@yahoo.com>
+
+ 10/5
+ ----
+print_cmd.c
+ - indirection_level_string: small change to only re-enable `x'
+ option after calling decode_prompt_string if it was on before. In
+ normal mode, it will be, but John Reiser <jreiser@bitwagon.com>
+ has a novel use for that code in conjunction with a pre-loaded
+ shared library that traces system call usage in shell scripts
+
+ 10/10
+ -----
+Makefile.in
+ - Fix from Mike Frysinger <vapier@gentoo.org> to avoid trying to
+ build y.tab.c and y.tab.h with two separate runs of yacc if
+ parse.y changes. Problem with parallel makes
+ - Fix from Mike Frysinger <vapier@gentoo.org> to avoid subdirectory
+ builds each trying to make version.h (and all its dependencies)
+
+lib/sh/Makefile.in
+ - remove some dependencies on version.h where it doesn't make sense
+
+variables.c
+ - initialize_shell_variables: while reading the environment, a shell
+ running in posix mode now checks for SHELLOPTS being readonly (it
+ gets set early on in main()) before trying to assign to it. It
+ saves an error message and the variable gets parsed as it should.
+ Fixes bug reported by Len Giambrone <Len.Giambrone@intersystems.com>
+
+ 10/14
+ -----
+doc/{bash.1,bashref.texi}
+ - add to the "duplicating file descriptors" description that >&word
+ doesn't redirect stdout and stderr if word expands to `-'
+ - add to the "appending standard output and standard error"
+ description a note that >&word, where word is a number or `-',
+ causes other redirection operators to apply for sh and Posix
+ compatibility reasons. Suggested by Greg Wooledge
+ <wooledg@eeg.ccf.org>
+
+ 10/15
+ -----
+pcomplete.c
+ - change pcomp_filename_completion_function to only run the filename
+ dequoting function in the cases (as best as it can figure) where
+ readline won't do it via rl_filename_completion_function. Based
+ on reports from <lolilolicon@gmail.com>
+
+ 10/19
+ -----
+bashline.c
+ - attempt_shell_completion: add call to set_directory_hook() to make
+ sure the rewrite functions are correct. It's cheap and doesn't
+ hurt
+ - command_word_completion_function: if completing a command name that
+ starts with `.' or `..', temporarily suppress the effects of the
+ `direxpand' option and restore the correct value after calling
+ rl_filename_completion_function. If it's enabled, the directory
+ name will be rewritten and no longer match `./' or `../'. Fixes
+ problem reported by Michael Kalisz <michael@kalisz.homelinux.net>
+
+ 10/22
+ -----
+builtins/history.def
+ - push_history: make sure remember_on_history is enabled before we
+ try to delete the last history entry -- the `history -s' command
+ might not have been saved. Fixes bug reported by
+ lester@vmw-les.eng.vmware.com
+
+lib/readline/complete.c
+ - rl_callback_read_char: add calls to a macro CALLBACK_READ_RETURN
+ instead of straight return; add same call at end of function.
+ Placeholder for future work in deinstalling signal handlers when
+ readline is not active
+
+ 10/25
+ -----
+expr.c
+ - exp2: catch arithmetic overflow when val1 == INTMAX_MIN and val2 == -1
+ for DIV and MOD and avoid SIGFPE. Bug report and pointer to fix
+ from Jaak Ristioja <jaak.ristioja@cyber.ee>
+ - expassign: same changes for arithmetic overflow for DIV and MOD
+
+ 10/28
+ -----
+subst.c
+ - parameter_brace_expand: allow pattern substitution when there is an
+ expansion of the form ${var/} as a no-op: replacing nothing with
+ nothing
+ - parameter_brace_patsub: don't need to check for PATSUB being NULL;
+ it never is
+
+flags.c
+ - if STRICT_POSIX is defined, initialize history_expansion to 0, since
+ history expansion (and its treatment of ! within double quotes) is
+ not a conforming posix environment. From austin-group issue 500
+
+lib/readline/histexpand.c
+ - history_expand: when processing a string within double quotes
+ (DQUOTE == 1), make the closing double quote inhibit history
+ expansion, as if the word were outside double quotes. In effect,
+ we assume that the double quote is followed by a character in
+ history_no_expand_chars. tcsh and csh seem to do this. This
+ answers a persistent complaint about history expansion
+
+ 10/29
+ -----
+make_cmd.c
+ - make_arith_for_command: use skip_to_delim to find the next `;'
+ when breaking the string between the double parens into three
+ separate components instead of a simple character loop. Fixes
+ bug reported by Dan Douglas <ormaaj@gmail.com>
+
+ 11/2
+ ----
+Makefile.in
+ - make libbuiltins.a depend on builtext.h to serialize its creation
+ and avoid conflict between multiple invocations of mkbuiltins.
+ Fix from Mike Frysinger <vapier@gentoo.org>
+
+ 11/5
+ ----
+findcmd.c
+ - user_command_matches: if stat(".", ...) returns -1, set st_dev
+ and st_ino fields in dotinfo to 0 to avoid same_file matches
+ - find_user_command_in_path: check stat(2) return the same way
+
+lib/glob/glob.c
+ - glob_vector: don't call strlen(pat) without checking pat == 0
+ - glob_dir_to_array: make sure to free `result' and all allocated
+ members before returning error due to malloc failure
+ - glob_vector: make sure to free `nextname' and `npat' on errors
+ (mostly when setting lose = 1)
+ - glob_vector: if flags & GX_MATCHDIRS but not GX_ALLDIRS, make
+ sure we free `subdir'
+ - glob_filename: when expanding ** (GX_ALLDIRS), make sure we
+ free temp_results (return value from glob_vector)
+
+lib/glob/xmbsrtowcs.c
+ - xdupmbstowcs: fix call to realloc to use sizeof (char *) instead
+ of sizeof (char **) when assigning idxtmp
+
+execute_cmd.c
+ - print_index_and_element: return 0 right away if L == 0
+ - is_dirname: fix memory leak by freeing `temp'
+ - time_command: don't try to deref NULL `command' when assigning
+ to `posix_time'
+ - shell_execve: null-terminate `sample' after READ_SAMPLE_BUF so it's
+ terminated for functions that expect that
+
+builtins/read.def
+ - read_builtin: don't call bind_read_variable with a potentially-null
+ string
+
+pcomplete.c
+ - gen_command_matches: don't call dispose_word_desc with a NULL arg
+ - gen_compspec_completions: fix memory leak by freeing `ret' before
+ calling gen_action_completions (tcs, ...). happens when
+ performing directory completion as default and no completions
+ have been generated
+ - gen_progcomp_completions: make sure to set foundp to 0 whenever
+ returning NULL
+ - it_init_aliases: fix memory leak by freeing alias_list before
+ returning
+
+bashline.c
+ - command_word_completion_function: don't call restore_tilde with a
+ NULL directory_part argument
+ - bash_directory_expansion: bugfix: don't throw away results of
+ rl_directory_rewrite_hook if it's set and returns non-zero
+ - bind_keyseq_to_unix_command: free `kseq' before returning error
+
+arrayfunc.c
+ - assign_array_element_internal: make sure `akey' is freed if non-null
+ before returning error
+ - assign_compound_array_list: free `akey' before returning error
+ - array_value_internal: free `akey' before returning error
+ - unbind_array_element: free `akey' before returning error
+
+subst.c
+ - array_length_reference: free `akey' before returning error in case
+ of expand_assignment_string_to_string error
+ - array_length_reference: free `akey' after call to assoc_reference
+ - skip_to_delim: if skipping process and command substitution, free
+ return value from extract_process_subst
+ - parameter_brace_substring: free `val' (vtype == VT_VARIABLE) before
+ returning if verify_substring_values fails
+ - parameter_brace_expand: remove two duplicate lines that allocate
+ ret in parameter_brace_substring case
+ - parameter_brace_expand: convert `free (name); name = xmalloc (...)'
+ to use `xrealloc (name, ...)'
+ - parameter_brace_expand: free `name' before returning when handling
+ ${!PREFIX*} expansion
+ - split_at_delims: fix memory leak by freeing `d2' before returning
+
+redir.c
+ - redirection_error: free `filename' if the redirection operator is
+ REDIR_VARASSIGN by assigning allocname
+
+eval.c
+ - send_pwd_to_eterm: fix memory leak by freeing value returned by
+ get_working_directory()
+
+builtins/cd.def
+ - change_to_directory: fix memory leak by freeing return value from
+ resetpwd()
+ - cd_builtin: fix memory leak by freeing value returned by dirspell()
+ - cd_builtin: fix memory leak by freeing `directory' if appropriate
+ before overwriting with return value from resetpwd()
+
+builtins/type.def
+ - describe_command: free `full_path' before overwriting it with return
+ value from sh_makepath
+
+builtins/complete.def
+ - compgen_builtin: fix memory leak by calling strlist_dispose (sl)
+ before overwriting sl with return value from completions_to_stringlist
+
+builtins/hash.def
+ - list_hashed_filename_targets: fix memory leak by freeing `target'
+
+make_cmd.c
+ - make_arith_for_command: free `init', `test', and `step' before
+ returning error on parse error
+
+jobs.c
+ - initialize_job_control: don't call move_to_high_fd if shell_tty == -1
+
+general.c
+ - check_dev_tty: don't call close with an fd < 0
+ - legal_number: deal with NULL `string' argument, return invalid
+
+lib/sh/fmtulong.c
+ - fmtulong: if the `base' argument is invalid, make sure we index
+ buf by `len-1' at maximum
+
+print_cmd.c
+ - print_deferred_heredocs: don't try to dereference a NULL `cstring'
+ - cprintf: make sure to call va_end (args)
+
+variables.c
+ - push_dollar_vars: fix call to xrealloc to use sizeof (WORD_LIST *)
+ instead of sizeof (WORD_LIST **)
+
+lib/sh/zmapfd.c
+ - zmapfd: if read returns error, free result and return -1 immediately
+ instead of trying to reallocate it
+
+ 11/6
+ ----
+execute_cmd.c
+ - cpl_reap: rewrote to avoid using pointer after freeing it; now builds
+ new coproc list on the fly while traversing the old one and sets the
+ right values for coproc_list when done
+
+ 11/12
+ -----
+builtins/set.def
+ - if neither -f nor -v supplied, don't allow a readonly function to
+ be implicitly unset. Fixes bug reported by Jens Schmidt
+ <jens.schmidt35@arcor.de>
+
+lib/readline/callback.c
+ - change CALLBACK_READ_RETURN to clear signal handlers before returning
+ from rl_callback_read_char so readline's signal handlers aren't
+ installed when readline doesn't have control. Idea from Jan
+ Kratochvil <jan.ktratochvil@redhat.com> and the GDB development
+ team
+
+pcomplete.h
+ - COPT_NOQUOTE: new complete/compgen option value
+
+builtins/complete.def
+ - noquote: new complete/compgen option; will be used to disable
+ filename completion quoting
+
+pcomplete.c
+ - pcomp_set_readline_variables: pay attention to COPT_NOQUOTE; turns
+ of rl_filename_quoting_desired if set; turns it on if unset (value
+ is inverted, since default is on)
+
+doc/bash.1,lib/readline/doc/rluser.texi
+ - document new -o noquote option to complete/compgen/compopt
+
+pathexp.c
+ - quote_string_for_globbing: if QGLOB_REGEXP, make sure characters
+ between brackets in an ERE bracket expression are not inappropriately
+ quoted with backslashes. This is a pretty substantial change,
+ should be stressed when opening bash up for alpha and beta tests.
+ Fixes bug pointed out by Stephane Chazleas
+ <stephane_chazelas@yahoo.fr>
+
+doc/{bash.1,bashref.texi}
+ - document that regexp matches can be inconsistent when quoting
+ characters in bracket expressions, since usual quoting characters
+ lose their meaning within brackets
+ - note that regular expression matching when the pattern is stored
+ in a shell variable which is quoted for expansion causes string
+ matching
+
+redir.h
+ - RX_SAVEFD: new flag value; notes that a redirection denotes an
+ fd used to save another even if it's not >= SHELL_FD_BASE
+
+redir.c
+ - do_redirection_internal: when deciding whether or not to reset the
+ close-on-exec flag on a restored file descriptor, trust the value
+ of redirect->flags & RX_SAVCLEXEC even if the fd is < SHELL_FD_BASE
+ if the RX_SAVEFD flag is set
+ - add_undo_redirect: set the RX_SAVEFD flag if the file descriptor
+ limit is such that the shell can't duplicate to a file descriptor
+ >= 10. Fixes a limitation that tripped a coreutils test reported
+ by Paul Eggert <eggert@cs.ucla.edu>
+
+ 11/19
+ -----
+doc/{bash.1,bashref.texi},lib/readline/doc/hsuser.texi
+ - make it clear that bash runs HISTFILESIZE=$HISTSIZE after reading
+ the startup files
+ - make it clear that bash runs HISTSIZE=500 after reading the
+ startup files
+ - make it clear that setting HISTSIZE=0 causes commands to not be
+ saved in the history list
+ - make it clear that setting HISTFILESIZE=0 causes the history file
+ to be truncated to zero size
+
+variables.c
+ - sv_histsize: change so setting HISTSIZE to a value less than 0
+ causes the history to be `unstifled'
+ - sv_histsize: change so setting HISTFILESIZE to a value less than 0
+ results in no file truncation
+ - make it clear that numeric values less than 0 for HISTFILESIZE or
+ HISTSIZE inhibit the usual functions
+
+ 11/23
+ -----
+parse.y
+ - save_input_line_state: add missing `return ls' at the end, since the
+ function is supposed to return its argument. Pointed out by
+ Andreas Schwab <schwab@linux-m68k.org>
+
+builtins/read.def
+ - skip over NUL bytes in input, as most modern shells seem to. Bug
+ report by Matthew Story <matt@tablethotels.com>
+
+lib/readline/vi_mode.c
+ - rl_vi_replace: set _rl_vi_last_key_before_insert to invoking key
+
+ 11/25
+ -----
+builtins/read.def
+ - read_builtin: if xrealloc returns same pointer as first argument,
+ don't bother with the remove_unwind_protect/add_unwind_protect pair
+ - read_builtin: set a flag (`reading') around calls to zread/zreadc
+ and readline()
+ - sigalrm: change to set flag (`sigalrm_seen') and only longjmp if
+ currently in read(2) (reading != 0)
+ - CHECK_ALRM: new macro, checks sigalrm_seen and longjmps if non-zero,
+ behavior of old SIGALRM catching function
+ - read_builtin: call CHECK_ALRM in appropriate places while reading
+ line of input. Fixes bug reported by Pierre Gaston
+ <pierre.gaston@gmail.com>
+
+lib/readline/vi_mode.c
+ - rl_vi_replace: initialize characters before printing characters in
+ vi_replace_keymap to their default values in vi_insertion_keymap,
+ since we're supposed to be in insert mode replacing characters
+ - rl_vi_replace: call rl_vi_start_inserting to set last command to
+ `R' for undo
+ - rl_vi_replace: set _rl_vi_last_key_before_insert to `R' for future
+ use by _rl_vi_done_inserting
+ - vi_save_insert_buffer: new function, broke out code that copies text
+ into vi_insert_buffer from _rl_vi_save_insert
+ - _rl_vi_save_replace: new function, saves text modified by
+ rl_vi_replace (using current point and vi_replace_count to figure
+ it out) to vi_replace_buffer
+ - _rl_vi_save_insert: call vi_save_insert_buffer
+ - _rl_vi_done_inserting: if _rl_vi_last_key_before_insert == 'R', call
+ _rl_vi_save_replace to save text modified in replace mode (uses
+ vi_save_insert_buffer)
+ - _rl_vi_replace_insert: new function, replaces the number of chars
+ in vi_insert_buffer after rl_point with contents ov vi_insert_buffer
+ - rl_vi_redo: call _rl_vi_replace_insert if last command == 'R' and
+ there's something in vi_insert_buffer. Fixes bug with `.' not
+ redoing the most recent `R' command, reported by Geoff Clare
+ <g.clare@opengroup.org> in readline area on savannah
+
+ 11/26
+ -----
+lib/readline/rlprivate.h
+ - RL_SIG_RECEIVED(): evaluate to non-zero if there is a pending signal
+ to be handled
+ - RL_SIGINT_RECEIVED(): evaluate to non-zero if there is a pending
+ SIGINT to be handled
+
+lib/readline/complete.c
+ - remove all mention of _rl_interrupt_immediately
+ - rl_completion_matches: check RL_SIG_RECEIVED after each call to
+ the entry function, call RL_CHECK_SIGNALS if true to handle the
+ signal
+ - rl_completion_matches: if RL_SIG_RECEIVED evaluates to true, free
+ and zero out the match_list this function allocated
+ - rl_completion_matches: if the completion entry function is
+ rl_filename_completion_function, free the contents of match_list,
+ because that function does not keep state and will not free the
+ entries; avoids possible memory leak pointed out by
+ Garrett Cooper <yanegomi@gmail.com>
+ - gen_completion_matches: if RL_SIG_RECEIVED evalutes to true after
+ calling rl_attempted_completion_function, free the returned match
+ list and handle the signal with RL_CHECK_SIGNALS; avoids
+ possible memory leak pointed out by Garrett Cooper
+ <yanegomi@gmail.com>
+ - gen_completion_matches: if RL_SIG_RECEIVED evaluates to true after
+ calling rl_completion_matches, free the returned match list and
+ handle the signal with RL_CHECK_SIGNALS
+
+lib/readline/util.c
+ - rl_settracefp: new utility function to set the tracing FILE *
+
+lib/readline/signals.c
+ - _rl_sigcleanup: pointer to a function that will be called with the
+ signal and a void * argument from _rl_handle_signal
+ - _rl_sigcleanarg: void * that the rest of the code can set to have
+ passed to the signal cleanup function
+ - _rl_handle_signal: if _rl_sigcleanup set, call as
+ (*_rl_sigcleanup) (sig, _rl_sigcleanarg)
+
+lib/readline/rlprivate.h
+ - extern declarations for _rl_sigcleanup and _rl_sigcleanarg
+
+lib/readline/complete.c
+ - _rl_complete_sigcleanup: signal cleanup function for completion code;
+ calls _rl_free_match_list on _rl_sigcleanarg if signal == SIGINT
+ - rl_complete_internal: before calling display_matches if what_to_do
+ == `?', set _rl_sigcleanup to _rl_complete_sigcleanup so the match
+ list gets freed on SIGINT; avoids possible memory leak pointed out
+ by Garrett Cooper <yanegomi@gmail.com>
+ - rl_complete_internal: in default switch case, call _rl_free_match_list
+ before returning to avoid memory leak
+
+doc/bashref.texi
+ - start at a set of examples for the =~ regular expression matching
+ operator, touching on keeping the pattern in a shell variable and
+ quoting portions of the pattern to remove their special meaning
+
+ 12/1
+ ----
+lib/glob/gmisc.c
+ - extglob_pattern: new function, returns 1 if pattern passed as an
+ argument looks like an extended globbing pattern
+
+lib/glob/glob.c
+ - skipname: return 0 immediately if extglob_pattern returns non-zero,
+ let the extended globbing code do the right thing with skipping
+ names beginning with a `.'
+ - mbskipname: return 0 immediately if extglob_pattern returns non-zero,
+ let the extended globbing code do the right thing with skipping
+ names beginning with a `.'. Fixes bug reported by Yongzhi Pan
+ <panyongzhi@gmail.com>
+
+ 12/2
+ ----
+lib/glob/smatch.c
+ - patscan, patscan_wc: no longer static so other parts of the glob
+ library can use them, renamed to glob_patscan, glob_patscan_wc
+
+lib/glob/glob.c
+ - extern declarations for glob_patscan, glob_patscan_wc
+ - wchkname: new function, does skipname on wchar_t pattern and dname,
+ old body of mbskipname after converting to wide chars
+ - extglob_skipname: new function, checks all subpatterns in an extglob
+ pattern to determine whether or not a filename should be skipped.
+ Calls skipname for each subpattern. Dname is only skipped if all
+ subpatterns indicate it should be. Better fix for bug reported by
+ Yongzhi Pan <panyongzhi@gmail.com>
+ - wextglob_skipname: wide-char version of extglob_skipname, calls
+ wchkname instead of calling back into mbskipname for each
+ subpattern to avoid problems with char/wchar_t mismatch
+ - skipname: call extglob_skipname if extglob_pattern returns non-zero
+ - mbskipname: call wextglob_skipname if extglob_pattern returns non-zero
+ - mbskipname: short-circuit immediately if no multibyte chars in
+ pattern or filename
+
+execute_cmd.c
+ - execute_cond_node: added parens to patmatch assignment statement to
+ make intent clearer
+
+ 12/3
+ ----
+configure.in,config.h.in
+ - check for imaxdiv, define HAVE_IMAXDIV if present
+
+expr.c
+ - expassign, exp2: use imaxdiv if available. Doesn't help with checks
+ for overflow from 10/25
+
+ 12/6
+ ----
+lib/readline/complete.c
+ - compute_lcd_of_matches: if we're ignoring case in the matches, only
+ use what the user typed as the lcd if it matches the first match
+ (after sorting) up to the length of what was typed (if what the
+ user typed is longer than the shortest of the possible matches, use
+ the shortest common length of the matches instead). If it doesn't
+ match, use the first of the list of matches, as if case were not
+ being ignored. Fixes bug reported by Clark Wang
+ <dearvoid@gmail.com>
+
+ 12/7
+ ----
+builtins/cd.def
+ - cd_builtin: add code to return error in case cd has more than one
+ non-option argument, conditional on CD_COMPLAINS define (which is
+ not defined anywhere)
+
+doc/{bash.1,bashref.texi}
+ - note that additional arguments to cd following the directory name
+ are ignored. Suggested by Vaclav Hanzl <hanzl@noel.feld.cvut.cz>
+
+ 12/10
+ -----
+lib/readline/input.c
+ - rl_read_key: don't need to increment key sequence length here; doing
+ it leads to an off-by-one error
+
+lib/readline/macro.c
+ - rl_end_kbd_macro: after off-by-one error with rl_key_sequence_length
+ fixed, can decrement current_macro_index by rl_key_sequence_length
+ (length of key sequence that closes keyboard macro)
+
+lib/readline/readline.c
+ - _rl_dispatch_subseq: fix extra increment of rl_key_sequence_length
+ when ESC maps to a new keymap and we're converting meta characters
+ to ESC+key
+ - _rl_dispatch_subseq: better increment of rl_key_sequence_length
+ before we dispatch to a function in the ISFUNC case (where the
+ second increment above should have happened)
+ - rl_executing_keyseq: the full key sequence that ended up executing
+ a readline command. Available to the calling application, maintained
+ by _rl_dispatch_subseq, indexed by rl_key_sequence_length
+ - rl_executing_key: the key that was bound to the currently-executing
+ readline command. Same as the `key' argument to the function
+
+lib/readline/readline.h
+ - rl_executing_keyseq: extern declaration
+ - rl_executing_key: extern declaration
+ - rl_key_sequence_length: declaration moved here from rlprivate.h,
+ now part of public interface
+
+lib/readline/rlprivate.h
+ - new extern declaration for _rl_executing_keyseq_size, buffer size
+ for rl_executing_keyseq
+
+lib/readline/doc/rltech.texi
+ - documented new variables: rl_executing_key, rl_executing_keyseq,
+ rl_key_sequence_length
+
+ 12/13
+ -----
+bashline.c
+ - bash_execute_unix_command: replace ad-hoc code that searches
+ cmd_xmap for correct command with call to rl_function_of_keyseq
+ using rl_executing_keyseq; now supports key sequences longer
+ than two characters. Fixes bug reported by Michael Kazior
+ <kazikcz@gmail.com>
+
+ 12/15
+ -----
+make_cmd.c
+ - make_function_def: don't null out source_file before calling
+ make_command so it can be used later on when the function definition
+ is executed
+
+execute_cmd.c
+ - execute_intern_function: second argument is now FUNCTION_DEF *
+ instead of COMMAND *
+ - execute_command_internal: call execute_intern_function with the
+ new second argument (the entire FUNCTION_DEF instead of just the
+ command member)
+ - execute_intern_function: if DEBUGGER is defined, call
+ bind_function_def before calling bind_function, just like
+ make_function_def does (might be able to take out the call in
+ make_function_def depending on what the debugger does with it).
+ Fixes bug reported by <dethrophes@motd005>
+
+expr.c
+ - more minor changes to cases of INTMAX_MIN % -1 and INTMAX_MIN / 1;
+ fix typos and logic errors
+
+ 12/16
+ -----
+bashline.c
+ - find_cmd_start: change flags to remove SD_NOSKIPCMD so it skips over
+ command substitutions and doesn't treat them as command separators
+ - attempt_shell_completion: instead of taking first return from
+ find_cmd_name as command name to use for programmable completion,
+ use loop to skip over assignment statements. Fixes problem reported
+ by Raphael Droz <raphael.droz+floss@gmail.com>
+ - attempt_shell_completion: if we don't find a command name but the
+ command line is non-empty, assume the other words are all assignment
+ statements and flag that point is in a command position so we can
+ do command name completion
+ - attempt_shell_completion: if the word being completed is the first
+ word following a series of assignment statements, and the
+ command line is non-empty, flag that point is in a command position
+ so we can do command name completion
+
+lib/readline/history.c
+ - history_get_time: atol -> strtol
+
+ 12/18
+ -----
+parse.y
+ - parser_in_command_position: external interface to the
+ command_token_position macro for use by other parts of the shell,
+ like the completion mechanism
+
+externs.h
+ - extern declaration for parser_in_command_position
+
+ 12/19
+ -----
+
+builtins/read.def
+ - read_builtin: make sure all calls to bind_read_variable are passed
+ a non-null string. Fixes bug reported by Dan Douglas
+ <ormaaj@gmail.com>
+
+bashline.c
+ - attempt_shell_completion: mark that we're in a command position if
+ we're at the start of the line and the parser is ready to accept
+ a reserved word or command name. Feature most recently suggested
+ by Peng Yu <pengyu.ut@gmail.com>
+
+ 12/21
+ -----
+lib/readline/bind.c
+ - _rl_escchar: return the character that would be backslash-escaped
+ to denote the control character passed as an argument ('\n' -> 'n')
+ - _rl_isescape: return 1 if character passed is one that has a
+ backslash escape
+ - _rl_untranslate_macro_value: new second argument: use_escapes, if
+ non-zero translate to backslash escapes where possible instead of
+ using straight \C-x for control character `x'. Change callers
+ - _rl_untranslate_macro_value: now global
+
+lib/readline/rlprivate.h
+ - _rl_untranslate_macro_value: extern declaration
+
+lib/readline/{macro.c,readline.h}
+ - rl_print_last_kbd_macro: new bindable function, inspired by patch
+ from Mitchel Humpherys
+
+lib/readline/funmap.c
+ - print-last-kbd-macro: new bindable command, bound to
+ rl_print_last_kbd_macro
+
+lib/readline/doc/{rluser.texi,readline.3},doc/bash.1
+ - print-last-kbd-macro: document.
+
+lib/readline/text.c
+ - _rl_insert_next: if we're defining a macro, make sure the key gets
+ added to the macro text (should really audit calls to rl_read_key()
+ and make sure the right thing is happening for all of them)
+
+bashline.[ch]
+ - print_unix_command_map: new function, prints all bound commands in
+ cmd_xmap using rl_macro_dumper in a reusable format
+
+builtins/bind.def
+ - new -X option: print all keysequences bound to Unix commands using
+ print_unix_command_map. Feature suggested by Dennis Williamson
+ (2/2011)
+
+doc/{bash.1,bashref.texi}
+ - document new `bind -X' option
+
+ 12/24
+ -----
+
+doc/{bash.1,bashref.texi}
+ - add a couple of sentences to the description of the case modification
+ operators making it clearer that each character of parameter is
+ tested against the pattern, and that the pattern should only attempt
+ to match a single character. Suggested by Bill Gradwohl
+ <bill@ycc.com>
+
+ 12/28
+ -----
+shell.c
+ - init_noninteractive: instead of calling set_job_control(0) to
+ unconditionally turn off job control, turn on job control if
+ forced_interactive or jobs_m_flag is set
+ - shell_initialize: call initialize_job_control with jobs_m_flag as
+ argument so `bash -m script' enables job control while running the
+ script
+
+jobs.c
+ - initialize_job_control: if the `force' argument is non-zero, turn on
+ job control even if the shell is not currently interactive
+ (interactive == 0)
+
+ 12/29
+ -----
+
+flags.h
+ - new extern declaration for jobs_m_flag
+
+builtins/{cd,set}.def,doc/{bash.1,bashref.texi}
+ - added text clarifying the descriptions of cd -L and -P, suggested by
+ Padraig Brady <p@draigbrady.com>
+ - slight change to the description of `set -P' about resolving symbolic
+ links
+
+lib/readline/doc/rluser.texi
+ - Added an example to the programmable completion section: _comp_cd,
+ a completion function for cd, with additional verbiage. Text
+ includes a reference to the bash_completion project
+
+ 1/1/2012
+ --------
+jobs.c
+ - set_job_status_and_cleanup: note that a job is stopped due to
+ SIGTSTP (any_tstped) if job_control is set; there's no need to
+ test interactive
+
+ 1/5
+ ---
+quit.h
+ - LASTSIG(): new macro, expands to signal number of last terminating
+ signal received (terminating_signal or SIGINT)
+
+trap.c
+ - first_pending_trap: returns lowest signal number with a trap pending
+ - trapped_signal_received: set to the last trapped signal the shell
+ received in trap_handler(); reset to 0 in run_pending_traps
+
+builtins/read.def
+ - read_builtin: changes to posix-mode (posixly_correct != 0) to make
+ `read' interruptible by a trapped signal. After the trap runs,
+ read returns 128+sig and does not assign the partially-read line
+ to the named variable(s). From an austin-group discussion started
+ by David Korn
+
+ 1/11
+ ----
+doc/{bash.1,bashref.texi}
+ - slight changes to the descriptions of the compat32 and compat40 shell
+ options to clarify their meaning
+
+ 1/12
+ ----
+lib/readline/{colors.[ch],parse-colors.[ch]}
+ - new files, part of color infrastructure support
+
+Makefile.in,lib/readline/Makefile.in
+ - arrange to have colors.o and parse-colors.o added to readline
+ library
+
+{configure,config.h}.in
+ - check for stdbool.h, define HAVE_STDBOOL_H if found
+
+ 1/14
+ ----
+lib/readline/bind.c
+ - colored_stats: new bindable variable, enables using colors to
+ indicate file type when listing completions
+
+lib/readline/complete.c
+ - _rl_colored_stats: new variable, controlled by colored-stats bindable
+ variable
+ - colored_stat_start, colored_stat_end: new functions to set and reset
+ the terminal color appropriately depending on the type of the
+ filename to be printed
+ - print_filename: changes to print colors if `colored-stats' variable
+ set. Changes contributed by Raphael Droz
+ <raphael.droz+floss@gmail.com>
+
+lib/readline/readline.c
+ - rl_initialize_everything: add call to _rl_parse_colors to parse
+ color values out of $LS_COLORS. May have to add to rl_initialize
+ to make more dynamic if LS_COLORS changes (which doesn't happen
+ very often, if at all)
+
+lib/readline/rlprivate.h
+ - _rl_colored_stats: new extern declaration
+
+lib/readline/doc/{readline.3,rluser.texi},doc/bash.1
+ - colored-stats: document new bindable readline variable
+
+lib/readline/colors.c
+ - _rl_print_color_indicator: call rl_filename_stat_hook before calling
+ lstat/stat so we can get color indicators for stuff like
+ $HOME/Applications
+
+lib/readline/complete.c
+ - stat_char: call rl_filename_stat_hook before calling lstat/stat
+
+findcmd.[ch],execute_cmd.c
+ - search_for_command: now takes a second `flags' argument; changed
+ header function prototype and callers
+ - search_for_command: if (flags & 1), put the command found in $PATH
+ into the command hash table (previous default behavior)
+
+execute_cmd.c
+ - is_dirname: call search_for_command with flags argument of 0 so it
+ doesn't try to put something in the command hash table
+
+bashline.c
+ - bash_command_name_stat_hook: a hook function for readline's
+ filename_stat_hook that does $PATH searching the same way that
+ execute_cmd.c:execute_disk_command() does it, and rewrites the
+ passed filename if found. Does not put names into command hash
+ table. This allows command name completion to take advantage
+ of `visible-stats' and `colored-stats' settings.
+ - executable_completion: new function, calls the directory completion
+ hook to expand the filename before calling executable_file or
+ executable_or_directory; change command_word_completion_function to
+ call executable_completion. This allows $HOME/bin/[TAB] to do
+ command completion and display alternatives
+
+ 1/17
+ ----
+pcomplete.c
+ - gen_command_matches: now takes a new second argument: the command
+ name as deciphered by the programmable completion code and used
+ to look up the compspec; changed callers (gen_compspec_completions)
+ - gen_shell_function_matches: now takes a new second argument: the
+ command that originally caused the completion function to be
+ invoked; changed callers (gen_compspec_completions))
+ - build_arg_list: now takes a new second argument: the command name
+ corresponding to the current compspec; changed callers
+ (gen_command_matches, gen_shell_function_matches)
+ - build_arg_list: now uses `cmd' argument to create $1 passed to
+ invoked command or shell function
+ - gen_compspec_completions: if we skipped a null command at the
+ beginning of the line (e.g., for completing `>'), add a new word for
+ it at the beginning of the word list and increment nw and cw
+ appropriately. This is all a partial fix for the shortcoming
+ pointed out by Sung Pae <sungpae@gmail.com>
+
+ 1/18
+ ----
+
+{configure,config.h}.in
+ - new check: check for AUDIT_USER_TTY defined in <linux/audit.h>,
+ define HAVE_DECL_AUDIT_USER_TTY if both are found
+
+lib/readline/rlconf.h
+ - ENABLE_TTY_AUDIT_SUPPORT: new define, allows use of the Linux kernel
+ tty auditing system if it's available and enabled
+
+lib/readline/util.c
+ - _rl_audit_tty: new function, send a string to the kernel tty audit
+ system
+
+lib/readline/rlprivate.h
+ - _rl_audit_tty: new extern declaration
+
+lib/readline/readline.c
+ - readline: call _rl_audit_tty with line to be returned before returning
+ it if the Linux tty audit system is available and it's been enabled
+ in rlconf.h Original patch from Miroslav Trmac; recent request
+ from Miroslav Lichvar <mlichvar@redhat.com>
+
+ 1/21
+ ----
+
+lib/readline/readline.c:
+ - _rl_dispatch_subseq: add an inter-character timeout for multi-char
+ key sequences. Suggested by <rogerx.oss@gmail.com>. Still needs
+ work to make a user-settable variable
+
+parse.y
+ - shell_getc: make code that uses the pop_alias dependent on ALIAS
+ define
+
+variables.h
+ - sv_tz: extern define should only depend on HAVE_TZSET
+
+expr.c
+ - expr_streval: if ARRAY_VARS is not defined, set lvalue->ind to -1;
+ move assignment to `ind' inside define
+ - expr_bind_array_element: declaration and uses need to be #ifdef
+ ARRAY_VARS
+
+arrayfunc.h
+ - AV_ALLOWALL, AV_QUOTED, AV_USEIND: define to 0 if ARRAY_VARS not
+ defined; used in subst.c unconditionally
+
+sig.h
+ - make the signal blocking functions not dependent on JOB_CONTROL
+
+sig.c
+ - sigprocmask: make the replacement definition not dependent on
+ JOB_CONTROL
+
+trap.c
+ - use BLOCK_SIGNAL/UNBLOCK_SIGNAL instead of code dependent on
+ HAVE_POSIX_SIGNALS and BSD signals
+
+ 1/24
+ ----
+
+print_cmd.c
+ - print_redirection_list: change the conditions under which
+ r_duplicating_output_word is mapped to r_err_and_out to more or
+ less match those used in redir.c. Fixes bug pointed out by
+ Dan Douglas <ormaaj@gmail.com>
+
+
+ 1/29
+ ----
+lib/readline/signals.c
+ - _rl_block_sigwinch,_rl_release_sigwinch: don't compile in bodies
+ unless SIGWINCH is defined. Fixes bug reported by Pierre Muller
+ <pierre.muller@ics-cnrs.unistra.fr>
+
+doc/{bash.1,bashref.texi}
+ - small modifications to the introduction to the REDIRECTION section
+ to describe how redirections can modify file handles
+ - small modification to the section describing base#n to make it
+ clearer that n can be denoted using non-numerics. From a posting
+ by Linda Walsh <bash@tlinx.org>
+
+ 2/2
+ ---
+builtins/printf.def
+ - printf_builtin: make sure vbuf is intialized and non-null when -v
+ is supplied, since other parts of the code assume that it's not
+ null (e.g., bind_printf_variable()). Fixes bug reported by Jim
+ Avera <james_avera@yahoo.com>
+
+ 2/4
+ ---
+lib/readline/undo.c
+ - _rl_free_undo_list: new function, old body of rl_free_undo_list,
+ frees undo entries in UNDO_LIST * passed as argument
+ - rl_free_undo_list: call _rl_free_undo_list
+
+lib/readline/rlprivate.h
+ - _rl_free_undo_list: new extern declaration
+ - _rl_keyseq_timeout: new extern declaration (see below)
+
+lib/readline/misc.c
+ - rl_clear_history: new function. Clears the history list and frees
+ all associated data similar to history.c:clear_history(), but
+ takes rl_undo_list into account and frees and UNDO_LISTs saved as
+ `data' members of a history list entry
+
+lib/readline/doc/rltech.texi
+ - rl_clear_history: documented
+
+lib/readline/readline.c
+ - _rl_keyseq_timeout: new variable to hold intra-key timeout value
+ from 1/21 fix; specified in milliseconds. Default value is 500
+ - _rl_dispatch_subseq: change to use _rl_keyseq_timeout as intra-key
+ timeout if it's greater than 0; no timeout if <= 0
+ - _rl_dispatch_subseq: don't check for queued keyboard input if we have
+ pushed or pending input, or if we're reading input from a macro
+
+lib/readline/bind.c
+ - keyseq-timeout: new bindable variable, shadows _rl_keyseq_timeout
+ - string_varlist: add keyseq-timeout
+ - sv_seqtimeout: new function to modify value of _rl_keyseq_timeout;
+ clamps negative values at 0 for now
+ - _rl_get_string_variable_value: return value for keyseq-timeout
+
+doc/bash.1,lib/readline/doc/{rluser.texi,readline.3}
+ - keyseq-timeout: documented
+
+lib/readline/isearch.c
+ - _rl_isearch_dispatch: modification to fix from 7/18 to not use
+ cxt->keymap and cxt->okeymap, since by the time this code is
+ executed, they are equal. Use `f' to check for rl_insert or
+ unbound func
+ - _rl_isearch_dispatch: if we're switching keymaps, not in
+ callback mode, and don't have pending or pushed input, use
+ _rl_input_queued to resolve a potentially ambiguous key sequence.
+ Suggested by Roger Zauner <rogerx.oss@gmail.com>
+ - _rl_isearch_dispatch: if we have changed keymaps and resolved to
+ an editing function (not self-insert), make sure we stuff the
+ right characters back onto the input after changing the keymap
+ back so the right editing function is executed after the search
+ is terminated. Rest of fix for bug reported by Roger Zauner
+ <rogerx.oss@gmail.com>
+
+ 2/5
+ ---
+builtins/gen-helpfiles.c
+ - new file: reads struct builtin and writes the long docs to files
+ in the `helpdirs' subdirectory. The filename is given in the
+ previously-unused `handle' member of the struct builtin. Links
+ with `tmpbuiltins.o', which is created by Makefile to have the
+ right long documentation. When not cross-compiling, gets the
+ right #defines based on configuration options from config.h instead
+ of trying to parse conditional parts of def files. Fixes
+ shortcoming pointed out by Andreas Schwab <schwab@linux-m68k.org>
+
+builtins/Makefile.in
+ - tmpbuiltins.c: new generated file, created to enable creation of
+ separate helpfiles based on correct #defines instead of trying to
+ parse conditional parts of def files
+ - gen-helpfiles: new program to generate helpfiles, links with
+ tmpbuiltins.o
+ - HELPFILES_TARGET: new target, substituted by configure to `helpdoc'
+ if separate helpfiles requested
+ - targets: new target, libbuiltins.a and $(HELPFILES_TARGET)
+ - CREATED_OBJECTS: new variable, holds created object files for
+ make clean; changed make clean to remove created objects
+ - helpdoc: changed to call gen-helpfiles instead of mkbuiltins
+
+Makefile.in
+ - when building libbuiltins.a, recursively call make with `targets'
+ argument to make sure separate helpfiles get built
+
+configure.in
+ - substitute `helpdoc' as value of HELPFILES_TARGET if
+ --enable-separate-helpfiles supplied as configure argument
+
+builtins/mkbuiltins.c
+ - `-nofunctions': new argument, causes mkbuiltins to not write value
+ for function implementing a particular builtin to struct builtin
+ and to write document file name to `handle' member of struct builtin
+ - no longer writes separate helpfiles; that is left to gen-helpfiles
+
+ 2/8
+ ---
+subst.c
+ - make sure last_command_exit_value is set to a non-zero value before
+ any calls to report_error, since `-e' set will short-circuit
+ report_error. Fixes bug reported by Ewan Mellor
+ <Ewan.Mellor@eu.citrix.com>
+
+variables.c
+ - make_local_array_variable: added second argument; if non-zero,
+ function will return an existing local associative array variable
+ instead of insisting on an indexed array
+
+variable.h,subst.c
+ - make_local_array_variable: changed prototype and caller
+
+builtins/declare.def
+ - declare_internal: add second arg to call to make_local_array_variable;
+ making_array_special, which indicates we're processing an
+ assignment like declare a[b]=c. Fixes seg fault resulting from
+ a being an already-declared local associative array variable in a
+ function. Ubuntu bash bug 928900.
+
+ 2/14
+ ----
+
+execute_cmd.c
+ - execute_command_internal: if redirections into or out of a loop fail,
+ don't try to free ofifo_list unless saved_fifo is non-zero. It's
+ only valid if saved_fifo is set
+
+ 2/15
+ ----
+{arrayfunc,braces,variables}.c
+ - last_command_exit_value: make sure it's set before any calls to
+ report_error, since -e will cause that to exit the shell
+
+builtins/common.c
+ - get_job_by_name: call internal_error instead of report_error so this
+ doesn't exit the shell
+
+ 2/18
+ ----
+builtins/evalstring.c
+ - parse_and_execute: make sure the file descriptor to be redirected to
+ is 1 before calling cat_file. One fix for bug reported by Dan Douglas
+ <ormaaj@gmail.com>
+
+parse.y
+ - read_token_word: don't return NUMBER if a string of all digits
+ resolves to a number that overflows the bounds of an intmax_t.
+ Other fix for bug reported by Dan Douglas <ormaaj@gmail.com>
+
+ 2/19
+ ----
+lib/sh/strtrans.c
+ - ansicstr: use 0x7f as the boundary for characters that translate
+ directly from ASCII to unicode (\u and \U escapes) instead of
+ UCHAR_MAX, since everything >= 0x80 requires more than one byte.
+ Bug and fix from John Kearney <dethrophes@web.de>
+
+builtins/printf.def
+ - tescape: ditto for printf \u and \U escape sequences
+
+ 2/20
+ ----
+lib/sh/unicode.c
+ - u32toutf8: fix to handle encodings up to six bytes long correctly
+ (though technically UTF-8 only has characters up to 4 bytes long).
+ Report and fix from John Kearney <dethrophes@web.de>
+ - u32toutf8: first argument is now an unsigned 32-bit quantity,
+ changed callers (u32cconv) to pass c instead of wc
+ - u32reset: new function, resets local static state to uninitialized
+ (locale information, currently)
+
+locale.c
+ - call u32reset whenever LC_CTYPE/LC_ALL/LANG is changed to reset the
+ cached locale information used by u32cconv. From a report from
+ John Kearney <dethrophes@web.de>
+
+ 2/21
+ ----
+doc/{bash,builtins}.1
+ - minor changes from Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
+
+lib/sh/unicode.c
+ - u32cconv: only assume you can directly call wctomb on the passed
+ value if __STDC_ISO_10646__ is defined and the value is <=
+ 0x7fffffff
+ - stub_charset: return locale as default instead of "ASCII", let
+ rest of code decide what to do with it
+
+lib/readline/parens.c
+ - _rl_enable_paren_matching: make paren matching work in vi insert
+ mode. Bug report from <derflob@derflob.de>
+
+ 2/22
+ ----
+lib/sh/shquote.c
+ - sh_backslash_quote: quote tilde in places where it would be
+ expanded. From a report from John Kearney <dethrophes@web.de>
+
+ 2/23
+ ----
+execute_cmd.c
+ - execute_pipeline: wrap the discard_unwind_frame call in #ifdef
+ JOB_CONTROL, since the frame is only created if JOB_CONTROL is
+ defined. Bug and fix from Doug Kehn <rdkehn@yahoo.com>
+
+ 2/25
+ ----
+error.c
+ - report_error: make sure last_command_exit_value is non-zero before
+ we call exit_shell, since the exit trap may reference it. Call
+ exit_shell with last_command_exit_value to allow exit statuses
+ other than 1
+
+unicode.c
+ - stub_charset: use local static buffer to hold charset, don't change
+ value returned by get_locale_var. Based on idea and code from
+ John Kearney <dethrophes@web.de>
+ - u32toutf16: function to convert unsigned 32-bit value (unicode) to
+ UTF-16. From John Kearney <dethrophes@web.de>
+ - u32cconv: call u32toutf16 if __STDC_ISO_10646__ defined and wchar_t
+ is two bytes, send result to wcstombs, return if not encoding error.
+ From John Kearney <dethrophes@web.de>
+ - u32cconv: return UTF-8 conversion if iconv conversion to local
+ charset is unsupported
+
+ 3/2
+ ---
+lib/readline/complete.c
+ - print_filename: if there is no directory hook, but there is a stat
+ hook, and we want to append a slash to directories, call the stat
+ hook before calling path_isdir on the expanded directory name.
+ Report and pointer to fix from Steve Rago <sar@nec-labs.com>
+
+ 3/3
+ ---
+builtins/evalstring.c
+ - parse_and_execute: fix to change of 2/18: make sure the file
+ descriptor being redirected to is 0 before calling cat_file when
+ we see something like $(< file). Real fix for bug reported by
+ Dan Douglas <ormaaj@gmail.com>
+
+subst.c
+ - parameter_brace_patsub: run the replacement string through quote
+ removal even if the expansion is within double quotes, because
+ the parser and string extract functions treat the quotes and
+ backslashes as special. If they're treated as special, quote
+ removal should remove them (this is the Posix position and
+ compatible with ksh93). THIS IS NOT BACKWARDS COMPATIBLE.
+
+ 3/4
+ ---
+lib/readline/complete.c
+ - rl_menu_complete: fix to make show-all-if-ambiguous and
+ menu-complete-display-prefix work together if both are set. Fix
+ from Sami Pietila <sami.pietila@gmail.com>
+
+ 3/5
+ ---
+bashline.c
+ - dircomplete_expand_relpath: new variable, if non-zero, means that
+ `shopt -s direxpand' should expand relative pathnames. Zero by
+ default, not user-settable yet
+ - bash_directory_completion_hook: if we have a relative pathname that
+ isn't changed by canonicalization or spell checking after being
+ appended to $PWD, then don't change what the user typed. Controlled
+ by dircomplete_expand_relpath
+
+ 3/7
+ ---
+m4/timespec.m4
+ - new macros, cribbed from gnulib and coreutils: find out whether we
+ have `struct timespec' and what file includes it
+
+m4/stat-time.m4
+ - new macros, cribbed from gnulib and coreutils: find out whether the
+ mtime/atime/ctime/etctime fields of struct stat are of type
+ struct timespec, and what the name is
+
+include/stat-time.h
+ - new file, cribbed from gnulib, with additions from coreutils: include
+ the right file to get the struct timespec define, or provide our own
+ replacement. Provides a bunch of inline functions to turn the
+ appropriate members of struct stat into `struct timespec' values,
+ zeroing out the tv_nsec field if necessary
+
+test.c
+ - include "stat-time.h" for the nanosecond timestamp resolution stuff
+ - stat_mtime: new function, returns struct stat and the mod time
+ normalized into a `struct timespec' for the filename passed as the
+ first argument
+ - filecomp: call stat_mtime instead of sh_stat for each filename
+ argument to get the mtime as a struct timespec
+ - filecomp: call timespec_cmp instead of using a straight arithmetic
+ comparison for the -nt and -ot operators, using timespec returned by
+ stat_mtime. Added functionality requested by by Werner Fink
+ <werner@suse.de> for systems that can support it
+
+ 3/10
+ ----
+include/posixdir.h
+ - REAL_DIR_ENTRY: remove dependency on _POSIX_SOURCE, only use feature
+ test macros to decide whether dirent.d_ino is present and usable;
+ define D_INO_AVAILABLE. Report and fix from Fabrizion Gennari
+ <fabrizio.ge@tiscali.it>
+ - D_FILENO_AVAILABLE: define if we can use dirent.d_fileno
+
+lib/sh/getcwd.c
+ - use D_FILENO_AVAILABLE to decide whether or not to compile in
+ _path_checkino and whether or not to call it. Report and initial
+ fix from Fabrizion Gennari <fabrizio.ge@tiscali.it>
+
+lib/readline/signals.c
+ - make sure all occurrences of SIGWINCH are protected by #ifdef
+
+sig.c
+ - make sure all occurrences of SIGCHLD are protected by #ifdef
+
+nojobs.c
+ - make sure SA_RESTART is defined to 0 if the OS doesn't define it
+
+version.c
+ - show_shell_version: don't use string literals in printf, use %s.
+ Has added benefit of removing newline from string to be translated
+
+trap.c
+ - queue_sigchld_trap: new function, increments the number of pending
+ SIGCHLD signals by the argument, which is by convention the number
+ of children reaped in a call to waitchld()
+
+trap.h
+ - queue_sigchld_trap: new extern declaration
+
+jobs.c
+ - waitchld: if called from the SIGCHLD signal handler (sigchld > 0),
+ then call queue_sigchld_trap to avoid running the trap in a signal
+ handler context. Report and original fix from Siddhesh Poyarekar
+ <siddhesh@redhat.com>
+
+lib/sh/unicode.c
+ - u32tocesc: take an unsigned 32-bit quantity and encode it using
+ ISO C99 string notation (\u/\U)
+ - u32cconv: call u32tocesc as a fallback instead of u32cchar
+ - u32cconv: call u32tocesc if iconv cannot convert the character.
+ Maybe do the same thing if iconv_open fails
+ - u32reset: call iconv_close on localconv if u32init == 1
+
+ 3/11
+ ----
+config-top.h
+ - CHECKWINSIZE_DEFAULT: new define, set to initial value of
+ check_window_size (shopt checkwinsize): 0 for off, 1 for on.
+ Default is 0
+
+{jobs,nojobs}.c
+ - check_window_size: default initial value to CHECKWINSIZE_DEFAULT
+
+ 3/13
+ ----
+doc/bashref.texi
+ - change text referring to the copying restrictions to that
+ recommended by the FSF (no Front-Cover Texts and no Back-Cover
+ Texts)
+
+lib/readline/doc/{history,rlman,rluserman}.texi
+ - change text referring to the copying restrictions to that
+ recommended by the FSF (no Front-Cover Texts and no Back-Cover
+ Texts)
+
+ 3/15
+ ----
+array.c
+ - LASTREF_START: new macro to set the starting position for an array
+ traversal to `lastref' if that's valid, and to the start of the array
+ if not. Used in array_reference, array_insert, array_remove
+ - array_remove: try to be a little smarter with lastref instead of
+ unconditionally invalidating it
+
+ 3/16
+ ----
+array.c
+ - array_insert: fix memory leak by deleting element to be added in the
+ case of an error
+
+ 3/18
+ ----
+lib/sh/mbschr.c
+ - mbschr: don't call mbrlen unless is_basic is false; devolves to a
+ straight character-by-character run through the string
+
+ 3/19
+ ----
+stringlib.c
+ - substring: use memcpy instead of strncpy, since we know the length
+ and are going to add our own NUL terminator
+
+ 3/20
+ ----
+subst.c
+ - parameter_brace_expand_rhs: if expand_string_for_rhs returns a quoted
+ null string (a list with one element for which
+ QUOTED_NULL(list->word->word) returns true), return the quoted null
+ and set the flags in the returned word to indicate it. Fixes bug
+ reported by Mark Edgar <medgar123@gmail.com>
+
+lib/sh/tmpfile.c
+ - use random(3) instead of get_random_number to avoid perturbing the
+ random sequence you get using $RANDOM. Bug report and fix from
+ Jurij Mihelic <jurij.mihelic@fri.uni-lj.si>
+
+ 3/21
+ ----
+config-top.h
+ - OPTIMIZE_SEQUENTIAL_ARRAY_ASSIGNMENT: define to 1 to optimize
+ sequential indexed array assignment patterns. Defined to 1 by
+ default
+
+array.c
+ - array_insert: if OPTIMIZE_SEQUENTIAL_ARRAY_ASSIGNMENT is defined,
+ start the search at lastref (see change from 3/15)
+
+ 3/27
+ ----
+print_cmd.c
+ - debug_print_word_list: new debugging function, prints a word list
+ preceded by an optional string and using a caller-specified
+ separator
+
+ 4/1
+ ---
+command.h
+ - W_ASSNGLOBAL: new flag, set to indicate declare -g
+
+execute_cmd.c
+ - fix_assignment_words: note that we have a -g argument to an assignment
+ builtin and set the W_ASSNGLOBAL flag in the variable word
+
+subst.c
+ - dump_word_flags: print out W_ASSNGLOBAL if present
+ - do_assignment_internal: only set ASS_MKLOCAL if W_ASSIGNARG is set
+ and W_ASSNGLOBAL is not. Don't want to create a local variable even
+ if variable_context is non-zero if ASSNGLOBAL is set. Fixes bug
+ reported by Bill Gradwohl <bill@ycc.com>
+
+ 4/7
+ ---
+lib/readline/readline.c
+ - _rl_dispatch_subseq: make the `keyseq-timeout' variable apply to
+ ESC processing when in vi mode. After hitting ESC, readline will
+ wait up to _rl_keyseq_timeout*1000 microseconds (if set) for
+ additional input before dispatching on the ESC and switching to
+ command/movement mode. Completes timeout work suggested by
+ <rogerx.oss@gmail.com>; this prompted by report from Barry Downes
+ <barry.downes@gmail.com>
+
+lib/sh/shmbchar.c
+ - sh_mbsnlen: new function, returns the number of (possibly multibyte)
+ characters in a passed string with a passed length, examining at most
+ maxlen (third argument) bytes
+
+externs.h
+ - sh_mbsnlen: extern declaration for new function
+
+shell.c
+ - exit_shell: call maybe_save_shell_history if remember_on_history is
+ set, not just in interactive shells. That means the history is
+ saved if history is enabled, regardless of whether or not the shell
+ is interactive
+
+doc/{bash.1,bashref.texi}
+ - TMOUT: fix description to make it explicit that TMOUT is the timeout
+ period for a complete line of input, not just any input. Fixes
+ problem reported in Ubuntu bug 957303:
+ https://bugs.launchpad.net/ubuntu/+source/bash/+bug/957303
+ - HISTFILE: document change to write history list to history file in
+ any shell with history enabled, not just interactive shells. This
+ seems to be more logical behavior. Suggested by Greg Wooledge
+ <wooledg@eeg.ccf.org>
+
+ 4/12
+ ----
+lib/readline/colors.h
+ - only include stdbool.h if HAVE_STDBOOL_H is defined
+ - if HAVE_STDBOOL_H is not defined, provide enough definition for the
+ library to use `bool', `true', and `false'
+
+lib/readline/parse-colors.[ch]
+ - don't try to include <stdbool.h> at all; rely on colors.h to do it
+
+lib/sh/snprintf.c
+ - vsnprintf_internal: only treat '0' as a flag to indicate zero padding
+ if `.' hasn't been encountered ((flags&PF_DOT) == 0); otherwise treat
+ it as the first digit of a precision specifier. Fixes bug reported
+ by Petr Sumbera <petr.sumbera@sun.com>
+
+ 4/15
+ ----
+lib/sh/snprintf.c
+ - vsnprintf_internal: if the '0' and '-' flags both occur, the '0'
+ flag is ignored -- Posix. Start of a series of fixes based on
+ tests and patches from Petr Sumbera <petr.sumbera@sun.com>
+ - PUT_PLUS: make sure PF_PLUS flag is specified before putting the `+'
+ - vsnprintf_internal: when '+' is read as a flag, don't set right-
+ justify flag if the LADJUST (`-') flag has already been supplied
+ - floating: make sure to output space padding before the `+', zero
+ padding after
+ - exponent: make sure to output space padding before the `+', zero
+ padding after
+ - exponent: only subtract one from the width for the decimal point
+ if we're really going to print one
+ - floating: use presence of PF_PLUS flag to decide whether to account
+ for the `+' in the padded field width. Ditto for exponent()
+
+ 4/16
+ ----
+lib/sh/snprintf.c
+ - vsnprint_internal: only reduce precision by 1 when processing the `g'
+ format if it's > 0. A precision of 0 should stay 0; otherwise it
+ gets set to -1 (NOT_FOUND) and converted to the default
+ - number, lnumber: if an explicit precision is supplied, turn off the
+ zero-padding flag and set the pad character back to space
+ - number, lnumber: only account for a `+' when performing the field
+ width calculation if the coversion is base 10; we don't add a `+'
+ for other bases
+
+ 4/18
+ ----
+tests/printf3.sub
+ - try using "perl -e 'print time'" to get the current time in seconds
+ since the epoch if "date +%s" is not available (solaris 8-10)
+
+ 4/19
+ ----
+tests/run-printf
+ - use cat -v instead of relying on diff -a being available to convert
+ control characters to ascii and avoid the dreaded "Binary files
+ /tmp/xx and printf.right differ"
+
+ 4/20
+ ----
+lib/sh/strftime.c
+ - incoporated new version from Aharon Robbins <arnold@skeeve.com>
+
+ 4/22
+ ----
+doc/{bash.1,bashref.texi}
+ - slight change to the description of /dev/tcp and /dev/udp
+
+subst.c
+ - match_wpattern: logic fix to the calculation of `simple' (was |=,
+ needs to be &=). Bug report from Mike Frysinger <vapier@gentoo.org>,
+ fix from Andreas Schwab <schwab@linux-m68k.org>
+
+bashline.c
+ - bash_filename_stat_hook: add code from bash_directory_completion_hook
+ that performs pathname canonicalization in the same way that cd and
+ other builtins will do
+
+ 4/25
+ ----
+execute_cmd.c
+ - execute_pipeline: change the call to move_to_high_fd to make it use
+ getdtablesize() and to not stomp on existing open file descriptors,
+ like the fd the shell is using to read a script. Bug report from
+ Greg Wooledge <wooledg@eeg.ccf.org>
+
+ 5/6
+ ---
+subst.c
+ - expand_word_internal: case '$': after calling param_expand and
+ setting had_quoted_null, set TEMP to null. The code that builds the
+ returned string at the end of the function will take care of making
+ and returning a quoted null string if there's nothing else in
+ ISTRING. If there is, the quoted null should just go away. Part of
+ fix for bug reported by Ruediger Kuhlmann <RKuhlmann@orga-systems.com>
+ - expand_word_internal: when processing ISTRING to build return value,
+ only set W_HASQUOTEDNULL in the returned word flags if the word is
+ a quoted null string AND had_quoted_null is set. Rest of fix
+
+ 5/9
+ ---
+variables.c
+ - bind_variable_internal: if we get an array variable here (implicit
+ assignment to index 0), call make_array_variable_value, which
+ dummies up a fake SHELL_VAR * from array[0]. This matters when
+ we're appending and have to use the current value
+ - bind_variable_internal: after computing the new value, treat assoc
+ variables with higher precedence than simple array variables; it
+ might be that a variable has both attributes set
+
+arrayfunc.c
+ - bind_array_var_internal: break code out that handles creating the
+ new value to be assigned to an array variable index into a new
+ function, make_array_variable_value. This handles creating a
+ dummy SHELL_VAR * for implicit array[0] assignment. Fixes bug
+ reported by Dan Douglas <ormaaj@gmail.com>
+
+arrayfunc.h
+ - make_array_variable_value: new extern declaration
+
+ 5/19
+ ----
+variables.c
+ - bind_int_variable: if an assignment statement like x=y comes in
+ from the expression evaluator, and x is an array, handle it like
+ x[0]=y. Fixes bug reported by Dan Douglas <ormaaj@gmail.com>
+
+ 5/24
+ ----
+
+braces.c
+ - mkseq: handle possible overflow and break the sequence generating
+ loop if it occurs. Fixes OpenSUSE bug 763591:
+ https://bugzilla.novell.com/show_bug.cgi?id=763591
+
+ 5/25
+ ----
+Makefile.in
+ - LDFLAGS_FOR_BUILD: add to compilation recipes for build tools
+ buildversion, mksignames, mksyntax
+ - LDFLAGS_FOR_BUILD: add to compilation recipes for test tools
+ recho, zecho, printenv, xcase
+
+builtins/Makefile.in
+ - LDFLAGS_FOR_BUILD: add to compilation recipes for build tools
+ gen-helpfiles, psize.aux
+
+variables.c
+ - bind_int_variable: if LHS is a simple variable name without an array
+ reference, but resolves to an array variable, call
+ bind_array_variable with index 0 to make x=1 equivalent to x[0]=1.
+ Fixes bug reported by Dan Douglas <ormaaj@gmail.com>
+
+ 5/27
+ ----
+subst.c
+ - expand_word_internal: make sure has_dollar_at doesn't get reset before
+ recursive calls to param_expand or expand_word_internal, since it has
+ to save state of what came before. Use temp variable and make sure
+ has_dollar_at is incremented if recursive call processes "$@".
+ Fixes bug reported by gregrwm <backuppc-users@whitleymott.net> and
+ supplemented by Dan Douglas <ormaaj@gmail.com>
+
+doc/{bash.1,bashref.texi}
+ - changes to the description of substring expansion inspired by
+ suggestions from Bill Gradwohl <bill@ycc.com>
+
+doc/bashref.texi
+ - added substring expansion examples inspired by suggestions from
+ Bill Gradwohl <bill@ycc.com>
+
+variables.c
+ - find_shell_variable: search for a variable in the list of shell
+ contexts, ignore the temporary environment
+ - find_variable_tempenv: search for a variable in the list of shell
+ contexts, force search of the temporary environment
+ - find_variable_notempenv: search for a variable in the list of shell
+ contexts, don't force search of the temporary environment
+
+variables.h
+ - find_shell_variable: extern declaration
+ - find_variable_tempenv: extern declaration
+ - find_variable_notempenv: extern declaration
+
+arrayfunc.c
+ - bind_array_variable: call find_shell_variable instead of calling
+ var_lookup directly
+
+findcmd.c
+ - search_for_command: call find_variable_tempenv instead of
+ find_variable_internal directly
+ - _find_user_command_internal: call find_variable_tempenv instead of
+ find_variable_internal directly
+
+builtins/setattr.def
+ - set_var_attribute: call find_variable_notempenv instead of
+ find_variable_internal directly
+ - show_name_attributes: call find_variable_tempenv instead of
+ find_variable_internal directly
+
+ 6/1
+ ---
+sig.c
+ - termsig_handler: don't try to save the shell history on a terminating
+ signal any more, since it just causes too many problems on Linux
+ systems using glibc and glibc malloc
+
+lib/readline/vi_mode.c
+ - rl_vi_change_to: change to correctly redo `cc', since `c' is not a vi
+ motion character. From Red Hat bug 813289
+ - rl_vi_delete_to: change to correctly redo `dd', since `d' is not a vi
+ motion character
+ - rl_vi_yank_to: change to correctly redo `yy', since `y' is not a vi
+ motion character
+
+ 6/4
+ ---
+lib/sh/mktime.c
+ - current versions of VMS do not need to include <stddef.h>. Fix from
+ John E. Malmberg <wb8tyw@qsl.net>
+
+ 6/5
+ ---
+lib/sh/eaccess.c
+ - sh_stat: instead of using a static buffer to do the DEV_FD_PREFIX
+ translation, use a dynamically-allocated buffer that we keep
+ resizing. Fixes potential security hole reported by David Leverton
+ <levertond@googlemail.com>
+
+ 6/5
+ ---
+braces.c
+ - expand_seqterm: check errno == ERANGE after calling strtoimax for
+ rhs and incr. Part of a set of fixes from Scott McMillan
+ <scotty.mcmillan@gmail.com>
+ - expand_seqterm: incr now of type `intmax_t', which changes
+ arguments to mkseq
+ - mkseq: a better fix for detecting overflow and underflow since it's
+ undefined in C and compilers `optimize' out overflow checks. Uses
+ ADDOVERFLOW and SUBOVERFLOW macros
+ - mkseq: use sh_imaxabs (new macro) instead of abs() for intmax_t
+ variables
+ - mkseq: don't allow incr to be converted to -INTMAX_MIN
+ - mkseq: make sure that strvec_create isn't called with a size argument
+ greater than INT_MAX, since it only takes an int
+
+ 6/6
+ ---
+braces.c
+ - mkseq: try and be smarter about not overallocating elements in
+ the return array if the increment is not 1 or -1
+
+ 6/7
+ ---
+parse.y
+ - history_delimiting_chars: if the parser says we're in the middle of
+ a compound assignment (PST_COMPASSIGN), just return a space to avoid
+ adding a stray semicolon to the history entry. Fixes bug reported
+ by "Davide Brini" <dave_br@gmx.com>
+
+ 6/8
+ ---
+bashline.c
+ - bash_directory_completion_hook: don't attempt spelling correction
+ on the directory name unless the direxpand option is set and we are
+ going to replace the directory name with the corrected one in the
+ readline line. Suggested by Linda Walsh <bash@tlinx.org>
+
+lib/sh/shquote.c
+ - sh_backslash_quote: now takes a third argument: flags. If non-zero,
+ tildes are not backslash-escaped. Have to handle both printf %q,
+ where they should be escaped, and filename completion, where they
+ should not when used as usernames
+
+externs.h
+ - sh_backslash_quote: declaration now takes a third argument
+
+builtins/printf.def
+ - printf_builtin: call sh_backslash_quote with 1 as third argument
+ so tildes get escaped
+
+{bashline,bracecomp}.c
+ - call sh_backslash_quote with 0 as third argument so tildes are not
+ escaped in completed words
+
+doc/bash.1
+ - add `coproc' to the list of reserved words. From a report by
+ Jens Schweikhardt <schweikh@schweikhardt.net>
+
+ 6/10
+ ----
+execute_cmd.c
+ - line_number_for_err_trap: now global, so parse_and_execute can save
+ and restore it with unwind-protect
+
+builtins/evalstring.c
+ - parse_prologue: save and restore line_number_for_err_trap along
+ with line_number
+ - restore_lastcom: new function, unwind-protect to restore
+ the_printed_command_except_trap
+ - parse_prologue: use restore_lastcom to save and restore the value
+ of the_printed_command_except_trap around calls to parse_and_execute
+ (eval/source/.)
+
+ 6/15
+ ----
+lib/readline/complete.c
+ - complete_fncmp: change filename comparison code to understand
+ multibyte characters, even when doing case-sensitive or case-mapping
+ comparisons. Fixes problem reported by Nikolay Shirokovskiy
+ <nshyrokovskiy@gmail.com>
+
+ 6/20
+ ----
+builtins/mapfile.def
+ - mapfile: move the line count increment and check for having read
+ the specified number of lines to the end of the loop to avoid
+ reading an additional line with zgetline. Fixes bug reported by
+ Dan Douglas <ormaaj@gmail.com>
+
+ 6/21
+ ----
+
+execute_cmd.c
+ - execute_pipeline: make sure `lastpipe_flag' is initialized to 0 on
+ all systems, since it's tested later in the function. Fixes bug
+ reported by John E. Malmberg <wb8tyw@qsl.net>
+
+ 6/22
+ ----
+mailcheck.c
+ - file_mod_date_changed: return 0 right away if mailstat() does not
+ return success. Fixes bug with using uninitialized values reported
+ by szymon.kalasz@uj.edu.pl
+
+builtins/set.def
+ - the `monitor' option is not available when the shell is compiled
+ without job control, since the underlying `m' flag is not available
+
+nojobs.c
+ - job_control: now declared as int variable, initialized to 0, never
+ modified
+
+jobs.h
+ - job_control: extern declaration no longer dependent on JOB_CONTROL
+
+execute_cmd.c
+ - execute_pipeline: made necessary changes so `lastpipe' shell option
+ is now available in all shells, even those compiled without
+ JOB_CONTROL defined
+
+ 6/23
+ ----
+lib/glob/glob.c
+ - glob_filename: check for interrupts before returning if glob_vector
+ returns NULL or an error. Bug reported by Serge van den Boom
+ <svdb@stack.nl>, fix from Andreas Schwab <schwab@linux-m68k.org>
+ - call run_pending_traps after each call to QUIT or test of
+ interrupt_state, like we do in mainline shell code
+ - glob_vector: don't call QUIT; in `if (lose)' code block; just free
+ memory, return NULL, and let callers deal with interrupt_state or
+ other signals and traps
+
+ 6/25
+ ----
+lib/readline/input.c
+ - rl_read_key: restructure the loop that calls the event hook a little,
+ so that the hook is called only after rl_gather_tyi returns no input,
+ and any pending input is returned first. This results in better
+ efficiency for processing pending input without calling the hook
+ on every input character as bash-4.1 did. From a report from
+ Max Horn <max@quendi.de>
+
+ 6/26
+ ----
+trap.c
+ - signal_is_pending: return TRUE if SIG argument has been received and
+ a trap is waiting to execute
+
+trap.h
+ - signal_is_pending: extern declaration
+
+lib/glob/glob.c
+ - glob_vector: check for pending SIGINT trap each time through the loop,
+ just like we check for interrupt_state or terminating_signal, and
+ set `lose = 1' so we clean up after ourselves and interrupt the
+ operation before running the trap. This may require a change later,
+ maybe call run_pending_traps and do that if run_pending_traps returns?
+
+variables.c
+ - sv_histtimefmt: set history_comment_character to default (`#') if
+ it's 0 when we're turning on history timestamps. The history code
+ uses the history comment character to prefix timestamps, and
+ leaving it at 0 effectively removes them from the history. From a
+ report to help-bash by Dennis Williamson <dennistwilliamson@gmail.com>
+
+ 6/27
+ ----
+lib/readline/signals.c
+ - rl_maybe_restore_sighandler: new function, sets handler for SIG to
+ HANDLER->sa_handler only if it's not SIG_IGN. Needs to be called
+ on same signals set using rl_maybe_set_sighandler, which does not
+ override an existing SIG_IGN handler (SIGALRM is ok since it does
+ the check inline; doesn't mess with SIGWINCH)
+
+ 6/30
+ ----
+variables.h
+ - additional defines for the new `nameref' variable attribute
+ (att_nameref): nameref_p, nameref_cell, var_setref
+
+variables.c
+ - find_variable_nameref: resolve SHELL_VAR V through chain of namerefs
+ - find_variable_last_nameref: resolve variable NAME until last in a
+ chain of possibly more than one nameref starting at shell_variables
+ - find_global_variable_last_nameref: resolve variable NAME until last
+ in a chain of possibly more than one nameref starting at
+ global_variables
+ - find_nameref_at_context: resolve SHELL_VAR V through chain of namerefs
+ in a specific variable context (usually a local variable hash table)
+ - find_variable_nameref_context: resolve SHELL_VAR V through chain of
+ namerefs following a chain of varible contexts
+ - find_variable_last_nameref_context: resolve SHELL_VAR V as in
+ find_variable_last_context, but return the final nameref instead of
+ what the final nameref resolves to
+ - find_variable_tempenv, find_variable_notempenv, find_global_variable,
+ find_shell_variable, find_variable: modified to follow namerefs
+ - find_global_variable_noref: look up a global variable without following
+ any namerefs
+ - find_variable_noref: look up a shell variable without following any
+ namerefs
+ - bind_variable_internal: modify to follow a chain of namerefs in the
+ global variables table; change to handle assignments to a nameref by
+ following nameref chain
+ - bind_variable: modify to follow chain of namerefs when binding to a
+ local variable
+ - unbind_variable: changes to unset nameref variables (unsets both
+ nameref and variable it resolves to)
+
+subst.c
+ - parameter_brace_expand_word: change to handle expanding nameref whose
+ value is x[n]
+ - parameter_brace_expand_indir: change to expand in ksh93-compatible
+ way if variable to be indirected is nameref and a simple (non-array)
+ expansion
+ - param_expand: change to expand $foo where foo is a nameref whose value
+ is x[n]
+
+execute_cmd.c
+ - execute_for_command: changes to implement ksh93 semantics when index
+ variable is a nameref
+
+builtins/setattr.def
+ - show_var_attributes: change to add `n' to flags list if att_nameref
+ is set
+
+builtins/set.def
+ - unset_builtin: changes to error messages to follow nameref variables
+
+builtins/declare.def
+ - document new -n option
+ - declare_internal: new `-n' and `+n' options
+ - declare_internal: handle declare -n var[=value] and
+ declare +n var[=value] for existing and non-existant variables.
+ Enforce restriction that nameref variables cannot be arrays.
+ Implement semi-peculiar ksh93 semantics for typeset +n ref=value
+
+ 7/5
+ ---
+variables.c
+ - unbind_variable: unset whatever a nameref resolves to, leaving the
+ nameref variable itself alone
+ - unbind_nameref: new function, unsets a nameref variable, not the
+ variable it references
+
+variables.h
+ - unbind_nameref: extern declaration
+
+builtins/set.def
+ - unset_builtin: modify to add -n option, which calls unbind_nameref
+ leaving unbind_variable for the usual case. This required slight
+ changes and additions to the test suite
+
+doc/{bash.1,bashref.texi}
+ - document namerefs and typeset/declare/local/unset -n
+
+ 7/13
+ ----
+lib/sh/casemod.c
+ - include shmbchar.h for is_basic and supporting pieces
+ - sh_casemod: use _to_wupper and _to_wlower to convert wide character
+ case instead of TOUPPER and TOLOWER. Fixes bug reported by
+ Dennis Williamson <dennistwilliamson@gmail.com>, fix from
+ Andreas Schwab <schwab@linux-m68k.org>
+ - cval: short-circuit and return ascii value if is_basic tests true
+ - sh_casemod: short-circuit and use non-multibyte case modification
+ and toggling code if is_basic tests true
+
+lib/readline/signals.c
+ - _rl_{block,release}_sigint: remove the code that actually blocks and
+ releases the signals, since we defer signal handling until calls to
+ RL_CHECK_SIGNALS()
+
+lib/readline/{callback,readline,util}.c
+ - if HAVE_POSIX_SIGSETJMP is defined, use sigsetjmp/siglongjmp without
+ saving and restoring the signal mask instead of setjmp/longjmp
+
+lib/readline/rltty.c
+ - prepare_terminal_settings: don't mess with IXOFF setting if
+ USE_XON_XOFF defined
+
+doc/{bash.1,bashref.texi}
+ - add some text to the description of set -e clarifying its effect
+ on shell functions and shell function execution. Suggested by
+ Rainer Blome <rainer.blome@gmx.de>
+
+bashline.c
+ - edit_and_execute_command: increment current_command_line_count before
+ adding partial line to command history (for command-oriented-history
+ because of rl_newline at beginning of function), then reset it to 0
+ before adding the dummy history entry to make sure the dummy entry
+ doesn't get added to previous incomplete command. Partial fix for
+ problem reported by Peng Yu <pengyu.ut@gmail.com>
+
+ 7/24
+ ----
+configure.in
+ - interix: define RECYCLES_PIDS. Based on a report from Michael
+ Haubenwallner <michael.haubenwallner@salomon.at>
+
+ 7/26
+ ----
+jobs.c
+ - make_child: call bgp_delete on the newly-created pid unconditionally.
+ Some systems reuse pids before cycling through an entire set of
+ CHILD_MAX/_SC_CHILD_MAX unique pids. This is no longer dependent
+ on RECYCLES_PIDS. Based on a report from Michael Haubenwallner
+ <michael.haubenwallner@salomon.at>
+
+support/shobj-conf
+ - Mac OS X: drop MACOSX_DEPLOYMENT_TARGET=10.3 from the LDFLAGS. We
+ can finally kill Panther
+
+ 7/28
+ ----
+subst.c
+ - command_substitute: make sure last_made_pid gets reset if make_child
+ fails
+
+execute_cmd.c
+ - execute_command_internal: case cm_simple: decide whether or not to
+ wait_for a child if already_making_children is non-zero, indicates
+ that there is an unwaited-for child. More of fix for bug report
+ from Michael Haubenwallner <michael.haubenwallner@salomon.at>
+
+jobs.c
+ - make_child: call delete_old_job (new_pid) unconditionally, don't
+ bother to check whether or not pid wrap occurred. Rest of fix for
+ bug report from Michael Haubenwallner
+ <michael.haubenwallner@salomon.at>
+
+ 7/29
+ ----
+shell.c
+ - subshell_exit: new function, exits the shell (via call to sh_exit())
+ after calling any defined exit trap
+
+externs.h
+ - subshell_exit: new extern declaration
+
+execute_cmd.c
+ - execute_command_internal: make sure to call subshell_exit for
+ {} group commands executed asynchronously (&). Part of fix for
+ EXIT trap bug reported by Maarten Billemont <lhunath@lyndir.com>
+
+sig.c
+ - reset_terminating_signals: make sure to set termsigs_initialized back
+ to 0, so a subsequent call to initialize_terminating_signals works
+ right. Rest of fix for bug reported by Maarten Billemont
+ <lhunath@lyndir.com>
+
+{execute_cmd,general,jobs,mailcheck,mksyntax,test}.c
+builtins/{cd,fc,pushd,ulimit}.def
+lib/malloc/getpagesize.h
+lib/sh/{clktck,fpurge,inet_aton,mailstat,oslib,pathcanon,pathphys,spell,strerror}.c
+ - make inclusion of <sys/param.h> dependent on HAVE_SYS_PARAM_H
+ consistently
+
+ 8/6
+ ---
+lib/readline/histexpand.c
+ - history_expand_internal: now takes an additional argument saying
+ whether the history expansion occurs within a quoted string, set to
+ the open quote character
+ - history_expand_internal: use new argument instead of checking prev
+ char and initializing quoted_search_delimiter, pass qc directly to
+ get_history_event, where it allows a matching quote to terminate a
+ string defining an event
+ - history_expand: change single-quote handling code so that if
+ history_quotes_inhibit_expansion is 0, single quotes are treated
+ like double quotes
+ - history_expand: change call to history_expand_internal to pass new
+ argument of `"' if double-quoted string, `'' if single-quoted string;
+ this lets history_expand decide what is a quoted string and what
+ is not
+
+ 8/7
+ ---
+configure.in
+ - AC_CANONICAL_BUILD: invoke for later use
+
+lib/readline/macro.c
+ - _rl_prev_macro_key: new function, inverse of _rl_next_macro_key:
+ backs up the index into the current macro by 1
+
+lib/readline/rlprivate.h
+ - _rl_prev_macro_key: extern declaration
+
+
+lib/readline/readline.c
+ - _rl_dispatch_subseq, _rl_subseq_result: don't call _rl_unget_char
+ if we're currently reading from a macro; call _rl_prev_macro_key
+ instead. Fixes bug reported by Clark Wang <clark.wang@oracle.com>
+
+ 8/13
+ ----
+builtins/evalstring.c
+ - evalstring(): new function, wrapper around parse_and_execute.
+ make sure we handle cases where parse_and_execute can call `return'
+ and short-circuit without cleaning up properly. We call
+ parse_and_execute_cleanup() then jump to the previous-saved return
+ location
+
+builtins/common.h
+ - extern declaration for evalstring()
+
+builtins/eval.def
+ - eval_builtin: make sure we handle `eval " ... return"' in contexts
+ where `return' is valid by calling evalstring(). Fixes bug with
+ `eval return' in sourced files reported by Clark Wang
+ <dearvoid@gmail.com>
+
+trap.c
+ - run_pending_traps: call evalstring instead of parse_and_execute.
+ XXX - still needs to handle saving and restoring token state in the
+ presence of `return'; could use unwind_protects for that
+
+builtins/mapfile.def
+ - run_callback: call evalstring instead of parse_and_execute
+
+ 8/15
+ ----
+bashline.c
+ - bash_filename_stat_hook: make sure we don't free local_dirname
+ before using it to canonicalize any expanded filename. Make sure
+ it always points to *dirname and only free it if we're replacing
+ it.
+
+lib/readline/complete.c
+ - append_to_match: make sure we call rl_filename_stat_hook with
+ newly-allocated memory to avoid problems with freeing it twice
+
+ 8/17
+ ----
+variables.c,config-top.h
+ - if ARRAY_EXPORT is defined to 1 when variables.c is compiled, the
+ code that allows indexed arrays to be exported is enabled and
+ included
+
+ 8/19
+ ----
+shell.c
+ - call start_debugger from main() only if dollar_vars[1] != 0 (close
+ enough to a non-interactive shell, since we can be interactive with
+ -i while running a shell script). Fixes oddity reported by
+ Techlive Zheng <techlivezheng@gmail.com>
+
+ 8/20
+ ----
+arrayfunc.c
+ - quote_array_assignment_chars: don't bother quoting if the word has
+ not been marked as an assignment (W_ASSIGNMENT)
+ - quote_array_assignment_chars: turn on W_NOGLOB in the word flags
+ so assignment statements don't undergo globbing. Partial fix for
+ problems reported by Dan Douglas <ormaaj@gmail.com>
+
+ 8/21
+ ----
+command.h
+ - W_NOBRACE: new word flag that means to inhibit brace expansion
+
+subst.c
+ - brace_expand_word_list: suppress brace expansion for words with
+ W_NOBRACE flag
+
+ 8/22
+ ----
+builtins/read.def
+ - read_builtin: don't call dequote_string on what we've read, even if
+ we saw an escape character, unless (input_string && *input_string).
+ We may have escaped an IFS whitespace character. Fixes seg fault
+ reported by <armandsl@gmail.com>
+
+execute_cmd.c
+ - execute_command_internal: set the_printed_command_except trap when
+ about to execute a ( ... ) user subshell. For now, set it only if
+ ERR is trapped; can relax that later. Fixes bug reported by
+ Mike Frysinger <vapier@gentoo.org>
+
+ 8/23
+ ----
+jobs.c
+ - remove references to first_pid and pid_wrap, since we're not using
+ them for anything anymore
+
+ 8/24
+ ----
+subst.c
+ - changes for W_NOBRACE everywhere appropriate: so it can be displayed
+ for debugging, and passed out of expand_word_internal
+
+doc/{bash.1,bashref.texi}
+ - small changes to make it clearer that the = and == operators are
+ equivalent, and will cause pattern matching when used with [[.
+ From a question from Michal Soltys <soltys@ziu.info>
+
+doc/bashref.texi
+ - some small formatting changes from Karl Berry <karl@freefriends.org>
+
+ 8/27
+ ----
+lib/readline/doc/{history,rlman,rluserman}.texi
+ - some small formatting changes from Karl Berry <karl@freefriends.org>
+
+arrayfunc.c
+ - assign_array_element_internal, assign_compound_array_list,
+ unbind_array_element, array_value_internal: changes to make
+ assignment statements to negative indices (a[-1]=2) and unsetting
+ array elements using negative indices (unset 'a[-1]') work.
+ From suggestions by Dennis Williamson <dennistwilliamson@gmail.com>
+ and Chris F. A. Johnson <chris@cfajohnson.com>
+
+subst.c
+ - array_length_reference: changes to make length references to array
+ elements using negative indices (${#a[-1]}) work
+
+ 8/28
+ ----
+doc/{bash.1,bashref.texi}
+ - document new treatment of negative indices to indexed arrays when
+ assigning, referencing, calculating length, and unsetting
+
+ 8/29
+ ----
+shell.c
+ - show_shell_usage: add -l to list of shell invocation options (short
+ for --login). From Red Hat bug 852469
+
+configure.ac
+ - renamed from configure.in, as latest autoconf versions want. Patches
+ Stefano Lattarini <stefano.lattarini@gmail.com>
+
+MANIFEST,Makefile.in,doc/bashref.texi,support/mkconffiles
+ - configure.in -> configure.ac
+
+ 9/1
+ ---
+
+parse.y
+ - read_token_word: allow words like {array[ind]} to be valid redirection
+ words for constructs like {x}<file
+
+redir.c
+ - redir_varassign: bind_var_to_int already handles array assignments,
+ so don't need to do anything more for things like {a[i]}<file
+ - redir_varvalue: changes to allow references to {a[i]} when
+ performing redirections using valid_array_reference and
+ get_array_value. Adds functionality requested most recently by
+ <unknown@vmw-les.eng.vmware.com>
+
+lib/readline/display.c
+ - update_line: if the first difference between the old and new lines
+ is completely before any invisible characters in the prompt, we
+ should not adjust _rl_last_c_pos, since it's before any invisible
+ characters. Fixed in two places
+ - prompt_modechar: return a character indicating the editing mode:
+ emacs (@), vi command (:), or vi insert (+)
+ - _rl_reset_prompt: new function, just calls rl_expand_prompt. Will be
+ inlined, placeholder for more changes
+ - expand_prompt: if show-mode-in-prompt is enabled, add a character to
+ the front of the prompt indicating the editing mode, adjusting the
+ various variables as appropriate to keep track of the number of
+ visible characters and number of screen positions
+
+lib/readline/bind.c
+ - show-mode-in-prompt: new bindable boolean variable, shadowed by
+ _rl_show_mode_in_prompt variable
+ - hack_special_boolean_var: call _rl_reset_prompt when toggling or
+ setting show-mode-in-prompt
+
+lib/readline/readline.c
+ - readline_internal_setup: make sure the correct vi mode keymap is set
+ before expanding the prompt string for the first time
+
+lib/readline/misc.c
+ - rl_emacs_editing_mode: make sure to call _rl_reset_prompt if we're
+ showing the editing mode in the prompt
+
+lib/readline/rlprivate.h
+ - _rl_reset_prompt, _rl_show_mode_in_prompt: extern declarations
+
+lib/readline/vi_mode.c
+ - rl_vi_insertion_mode: call _rl_reset_prompt
+ - rl_vi_movement_mode: call _rl_reset_prompt. Finishes changes for
+ showing mode in prompt string, originally requested by Miroslav
+ Koskar <mkoskar@gmail.com> and most recently by Jordan Michael
+ Ziegler <jziegler@bnl.gov>
+
+doc/bash.1,lib/readline/doc/{readline.3,rluser.texi}
+ - document new show-mode-in-prompt variable, off by default
+
+ 9/3
+ ---
+
+jobs.c
+ - set_childmax: new function, external mechanism for other parts of
+ the shell to set js.c_childmax, the number of saved exited child
+ statuses to remember
+jobs.h
+ - set_childmax: extern declaration
+
+variables.c
+ - CHILD_MAX: new special variable, with sv_childmax function to
+ run when it changes. Setting CHILD_MAX to a value greater than
+ zero but less than some maximum (currently 8192) sets the number of
+ exited child statuses to remember. set_childmax (jobs.c) ensures
+ that the number does not drop below the posix-mandated minimum
+ (CHILD_MAX)
+
+doc/{bash.1,bashref.texi}
+ - CHILD_MAX: document new meaning and action when variable is set
+
+ 9/5
+ ---
+redir.c
+ - redir_varassign: call stupidly_hack_special_variables after
+ assigning fd number to specified variable, so we can use constructs
+ like {BASH_XTRACEFD}>foo. Suggested by Pierre Gaston
+ <pierre.gaston@gmail.com>
+
+ 9/8
+ ---
+expr.c
+ - readtok: invalidate previous contents of `curlval' before freeing
+ and reallocating tokstr (which, chances are, will get the same
+ pointer as before and render curlval inconsistent). Fixes other
+ bug reported by Dan Douglas <ormaaj@gmail.com>
+
+ 9/9
+ ---
+lib/readline/complete.c
+ - rl_username_completion_function: protect call to setpwent() with
+ #ifdef (HAVE_GETPWENT)/#endif. Fixes bug reported by
+ Gerd Hofmann <gerd.hofmann.nbg@googlemail.com>
+
+lib/readline/display.c
+ - rl_message: second and subsequent calls to rl_message can result in
+ local_prompt being overwritten with new values (e.g., from the
+ successive calls displaying the incremental search string). Need
+ to free before overwriting if it's not the same as the value saved
+ in saved_local_prompt. Fixes memory leak reported by
+ Wouter Vermaelen <vermaelen.wouter@gmail.com>
+
+lib/readline/{terminal.c,rlprivate.h}
+ - move CUSTOM_REDISPLAY_FUNC and CUSTOM_INPUT_FUNC defines from
+ terminal.c to rlprivate.h so other files can use them
+
+expr.c
+ - expr_streval: if noeval is non-zero, just return 0 right away,
+ short-circuiting evaluation completely. readtok will leave curtok
+ set correctly without re-entering the evaluator at all. Rest of
+ fix for bug reported by Dan Douglas <ormaaj@gmail.com>
+
+ 9/11
+ ----
+
+parse.y
+ - parse_comsub: make sure the `reserved word ok in this context' flag
+ is preserved after we read `do' followed by whitespace. Fixes bug
+ reported by Benoit Vaugon <benoit.vaugon@gmail.com>
+
+ 9/13
+ ----
+configure.ac,config.h.in
+ - enable-direxpand-default: new configure option, turns the `direxpand'
+ shell option on by default
+
+bashline.c
+ - dircomplete_expand, dircomplete_expand_relpath: initialize to 1 if
+ DIRCOMPLETE_EXPAND_DEFAULT is defined and non-zero
+
+doc/bashref.texi
+ - enable-direxpand-default: document new configure option
+
+ 9/14
+ ----
+shell.c
+ - --protected: make option valid only when wordexp is compiled into
+ the shell. Fix from Roman Rakus <rrakus@redhat.com>
+
+configure.ac
+ - HP NonStop (*-nsk*): compile --without-bash-malloc. Change from
+ Joachim Schmitz <jojo@schmitz-digital.de>
+
+ 9/16
+ ----
+subst.c,execute_cmd.c,lib/glob/sm_loop.c,lib/sh/shquote.c
+ - minor code cleanups from Joachim Schmitz <jojo@schmitz-digital.de>
+
+lib/readline/colors.h
+ - workaround for HP NonStop compiler issue with <stdbool.h> from
+ Joachim Schmitz <jojo@schmitz-digital.de>
+
+ 9/17
+ ----
+builtins/printf.def
+ - printf_builtin: handle localtime returning NULL, as can happen when
+ encountering overflow. Bug report and initial fix from
+ Eduardo A. Bustamante López <dualbus@gmail.com>
+
+doc/{bash.1,bashref.texi}
+ - emphasize that brace expansion using character ranges ({a..c}) acts
+ as if the C locale were in use. Prompted by message from
+ Marcel Giannelia <info@skeena.net>
+
+ 9/20
+ ----
+lib/sh/wcsnwidth.c
+ - wcsnwidth: new function, variant of wcwidth, returns the number of
+ wide characters from a string that will be displayed to not exceed
+ a specified max column position
+
+ 9/21
+ ----
+builtins/help.def
+ - show_builtin_command_help: break code that displays the short-doc
+ for each builtin in two columns into a new function: dispcolumn
+ - wdispcolumn: multibyte-char version of dispcolumn; uses wide
+ chars and printf "%ls" format. Fixes problem reported by
+ Nguyá»n Thái Ngá»c Duy <pclouds@gmail.com>
+
+ 9/22
+ ----
+execute_cmd.c
+ - execute_disk_command: before running the command-not-found hook,
+ call kill_current_pipeline() to make sure we don't add processes
+ to an existing pipeline or wait for processes erroneously
+
+ 9/23
+ ----
+lib/readline/input.c
+ - rl_input_available_hook: new hook function, called from
+ _rl_input_available (or _rl_input_queued) to return whether or not
+ input is available wherever the input source is
+
+lib/readline/doc/rltech.texi
+ - rl_input_available_hook: document
+
+ 9/27
+ ----
+lib/glob/sm_loop.c:
+ - GMATCH: after one or more `*', an instance of ?(x) can match zero or
+ 1 times (unlike ?, which has to match one character). The old code
+ failed if it didn't match at least once. Fixes `a*?(x)' bug.
+ - GMATCH: if we hit the end of the search string, but not the end of
+ the pattern, and the rest of the pattern is something that can
+ match the NUL at the end of the search string, we should successfully
+ match. Fixes `a*!(x)' bug reported by <hans1worst@gmail.com>
+
+ 10/2
+ ----
+command.h
+ - add c_lock member to coproc structure for future use to tell who is
+ manipulating it
+
+execute_cmd.c
+ - execute_coproc: block SIGCHLD while parent is forking coproc
+ process and adding pid to sh_coproc struct to avoid race condition
+ where child is reaped before the pid is assigned and the coproc is
+ never marked as having died. Fixes race condition identified by
+ Davide Baldini <baldiniebaldini@gmail.com>
+ - add assignments to c_lock member of struct coproc in various
+ functions that manipulate it; was used to identify race condition
+ - coproc_pidchk: don't call coproc_dispose to avoid using malloc and
+ other functions in a signal handler context
+ - coproc_dispose: call BLOCK_SIGNAL/UNBLOCK_SIGNAL for SIGCHLD while
+ manipulating the sh_coproc struct
+
+ 10/6
+ ----
+lib/readline/complete.c
+ - rl_display_match_list: if printing completions horizontally, don't
+ bother with spacing calculations if limit == 1, which means we are
+ printing one completion per line no matter what. Fixes bug
+ reported by David Kaasen <kaasen@nvg.ntnu.no>
+
+ 10/7
+ ----
+builtins/declare.def
+ - declare_internal: add error checking for nameref attribute and
+ variable assignments: self-references, attempts to make an array
+ variable a nameref
+
+subst.c
+ - parameter_brace_expand: handle parameter_brace_expand_word returning
+ &expand_param_fatal or &expand_param_error and return the appropriate
+ error value
+ - parameter_brace_expand_word: if a nameref variable's value is not a
+ valid identifier, return an error
+ - param_expand: if a nameref variable's value is not a valid identifier,
+ return an error
+
+test.c
+ - unary_operator: add new -R variable, returns true if variable is set
+ and has the nameref attribute. From ksh93
+
+builtins/test.def
+ - add -R to description of conditional commands for help test
+
+doc/{bash.1,bashref.texi}
+ - document new -R unary conditional operator
+
+ 10/13
+ -----
+trap.c
+ - check_signals_and_traps: new function, convenience function for the
+ rest of the shell to check for pending terminating and interrupt
+ signals, and to check for and process any pending traps
+ - any_signals_trapped: new function, returns non-zero if any signals
+ are trapped and -1 if not
+
+trap.h
+ - extern declaration for check_signals_and_traps
+
+bashline.c
+ - bashline_reset: make sure we reset the event hook
+ - bash_event_hook: call check_signals_and_traps instead of just
+ checking for terminating signals so we can run pending traps and
+ react to interrupts, and reset the event hook when we're done
+
+
+ 10/14
+ -----
+trap.c
+ - trap_handler: if executing in a readline signal handler context,
+ call bashline_set_event_hook to install bash_event_hook to process
+ the signal (if bash cares about it)
+
+sig.c
+ - sigint_sighandler: call bashline_set_event_hook to set the event
+ hook if we're executing in a readline signal handler context
+
+lib/readline/input.c
+ - rl_getc: call RL_CHECK_SIGNALS if read returns -1/EINTR and the caught
+ signal is SIGINT or SIGQUIT rather than waiting until the next time
+ around the loop
+ - rl_getc: call rl_event_hook after calling RL_CHECK_SIGNALS to allow
+ an application signal handler to set the event hook in its own
+ signal handler (e.g., like bash trap_handler or sigint_sighandler)
+
+
+parse.y
+ - yy_readline_get: don't set interrupt_immediately before we call
+ readline(). Inspired by report from lanshun zhou
+ <zls.sogou@gmail.com>
+
+input.c
+ - getc_with_restart: add call to run_pending_traps after call to
+ CHECK_TERMSIG
+
+lib/sh/zread.c
+ - zread: call check_signals_and_traps if read() returns -1/EINTR
+ instead of just ignoring the EINTR and deferring handling any
+ signal that generated it
+
+builtins/mapfile.def
+ - mapfile: don't set interrupt_immediately before calling zgetline()
+ (which uses zread internally)
+
+builtins/read.def
+ - read_builtin: don't set interrupt_immediately before calling zread
+ (moved code around so that it was only being set right around calls
+ to zread to avoid signal handler conflicts). Inspired by report
+ from lanshun zhou <zls.sogou@gmail.com>
+ - edit_line: don't set interrupt_immediately around call to readline()
+ - include shmbutil.h
+ - read_builtin: don't call read_mbchar unless is_basic(c) returns
+ false for the character we just read
+
+ 10/15
+ -----
+sig.c
+ - throw_to_top_level: if interrupt_state is non-zero, make sure that
+ last_command_exit_value reflects 128+SIGINT if it's not already
+ greater than 128
+
+ 10/20
+ -----
+builtins/wait.def
+ - WAIT_RETURN: set wait_signal_received back to 0 for the potential
+ next call to wait
+
+quit.h
+ - CHECK_WAIT_INTR: macro to check whether trap_handler handled a
+ signal and set wait_signal_received; longjmp to wait_intr_buf in
+ that case
+
+jobs.c
+ - wait_for, waitchld: call CHECK_WAIT_INTR at the same places we call
+ CHECK_TERMSIG to check for terminating signals
+ - wait_sigint_handler: don't longjmp out of the wait builtin unless
+ interrupt_immediately is set; otherwise just SIGRETURN from the
+ handler
+ - wait_sigint_handler: if interrupt_immediately not set, but we are
+ executing in the wait builtin and SIGINT is not trapped, treat it
+ as a `normally received' SIGINT: restore the signal handler and
+ send SIGINT to ourselves
+ - waitchld: when in posix mode and running SIGCHLD traps, don't longjmp
+ to wait_intr_buf (and let wait be interrupted) if we're running from
+ a signal handler. Wait for CHECK_WAIT_INTR to do the longjmp.
+ run_pending_traps will run the SIGCHLD trap later
+
+nojobs.c
+ - reap_zombie_children, wait_for_single_pid, wait_for: call
+ CHECK_WAIT_INTR where we call CHECK_TERMSIG
+ - wait_sigint_handler: don't longjmp out of the wait builtin unless
+ interrupt_immediately is set; otherwise just SIGRETURN from the
+ handler
+
+trap.c
+ - trap_handler: make sure wait_signal_received is set if the wait
+ builtin is executing, and only longjmp if interrupt_immediately is
+ set. This whole set of fixes was prompted by report from
+ lanshun zhou <zls.sogou@gmail.com>
+
+ 10/24
+ -----
+lib/glob/glob.c
+ - glob_filename: only check directory_name for globbing chars if
+ it's of non-zero length
+
+lib/sh/strchrnul.c
+ - new simpler implementation
+
+subst.c
+ - command_substitute: call set_shellopts after turning off errexit
+ in subshells so it's reflected in $SHELLOPTS
+
+ 11/7
+ ----
+builtins/evalstring.c
+ - parse_and_execute: treat ERREXIT case like reader_loop does: set
+ variable_context to 0 before longjmping back to top_level. Don't
+ run the unwind-protect context to avoid side effects from popping
+ function contexts. Part of fix for problem reported by Nikolai
+ Kondrashov <nikolai.kondrashov@redhat.com>
+
+execute_cmd.c
+ - execute_simple_command: call unlink_fifo_list only if this is the
+ last element of a pipeline (or not in a pipeline), rather than for
+ every child. Fixes difference in behavior between /dev/fd and
+ FIFOs reported by Zev Weiss <zev@bewilderbeest.net>
+ - execute_null_command: do the same thing in the parent branch after
+ make_child
+
+ 11/14
+ -----
+subst.c
+ - parameter_brace_expand: a variable is null if it's special ($@, $*),
+ the expansion occurs within double quotes, and the expansion turns
+ into a quoted null. Fixes debian bug 692447 reported by
+ Matrosov Dmitriy <sgf.dma@gmail.com>
+
+jobs.c
+ - run_sigchld_trap: make sure `running_trap' sentinel is set
+ appropriately
+ - waitchld: only run the sigchld trap if we're not in a signal
+ handler, not running a trap, and executing the wait builtin.
+ Otherwise, queue for later handling. We still run one instance
+ of the trap handler per exited child. Bulk of fix for bug
+ reported by Elliott Forney <idfah@cs.colostate.edu>
+
+trap.c
+ - queue_sigchld_trap: set catch_flag so run_pending_traps notices,
+ and set trapped_signal_received for completeness. Rest of fix
+ for bug reported by Elliott Forney <idfah@cs.colostate.edu>
+
+lib/malloc/malloc.c
+ - block_signals: renamed to _malloc_block_signals, made public
+ - unblock_signals: renamed to _malloc_unblock_signals, made public
+
+lib/malloc/imalloc.h
+ - extern declarations for _malloc_{un,}block_signals
+
+lib/malloc/table.c
+ - mregister_alloc, mregister_free: block signals around table
+ manipulation
+
+ 11/15
+ -----
+trap.c
+ - run_pending_traps: set SIG_INPROGRESS flag around calls to
+ run_sigchld_handler so other parts of the shell know that the
+ SIGCHLD trap handler is executing
+ - run_pending_traps: if we get a situation where we are looking at
+ running a SIGCHLD trap but the trap string is IMPOSSIBLE_TRAP_HANDLER
+ and the SIG_INPROGRESS flag is set, just skip it. This is possible
+ if run_pending_traps is called from a SIGCHLD trap handler run by
+ run_sigchld_trap
+
+doc/bash.1,lib/readline/doc/{rluser.texi,readline.3}
+ - corrected description of the effect of `set history-size 0'. Report
+ from Vesa-Matti J Kari <vmkari@cc.helsinki.fi>
+
+include/stdc.h
+ - CPP_STRING: new define, replaces __STRING
+
+lib/malloc/{malloc.c,imalloc.h}
+ - replace __STRING with CPP_STRING
+
+ 11/16
+ -----
+lib/readline/bind.c
+ - sv_histsize: if argument evaluates to a value < 0, unstifle the
+ history
+
+ 11/22
+ -----
+redir.c
+ - do_redirection_internal: if we have REDIR_VARASSIGN set in the
+ redirection flags and we set up `redirector' using fcntl or dup2,
+ don't add a redirect to make sure it stays open. Let the
+ script programmer manage the file handle. Fixes bug reported by
+ Sam Liddicott <sam@liddicott.com>
+
+ 11/24
+ -----
+jobs.c
+ - wait_for_any_job: new function, waits for an unspecified background
+ job to exit and returns its exit status. Returns -1 on no background
+ jobs or no children or other errors. Calls wait_for with new
+ sentinel value ANY_PID
+ - wait_for: changes to handle argument of ANY_PID: don't look up or
+ try to modify the child struct, only go through the wait loop once.
+ Return -1 if waitpid returns no children
+
+jobs.h
+ - ANY_PID: new define
+
+builtins/wait.def
+ - new option: -n. Means to wait for the next job and return its exit
+ status. Returns 127 if there are no background jobs (or no
+ children). Feature most recently requested by Elliott Forney
+ <idfah@cs.colostate.edu>
+
+doc/{bash.1,bashref.texi}
+ - document new `wait -n' option
+
+execute_cmd.c
+ - execute_command_internal: save make_command_string () result in a
+ temp variable before calling savestring() on it; avoids evaluating
+ make_command_string() result twice. Fix from John E. Malmberg
+ <wb8tyw@qsl.net>
+
+ 11/28
+ -----
+
+builtins/declare.def
+ - declare_internal: if an array variable is declared using `declare -a'
+ or `declare -A', but not assigned a value, set the `invisible'
+ attribute so the variable does not show up as set. Fix for bug
+ about variable initialization reported by Tim Friske <me@timfriske.com>
+
+builtins/{mapfile,read}.def
+ - after calling find_or_make_array_variable, make sure the invisible
+ flag is turned off, in case the variable was declared previously
+ using `declare -a' or `declare -A'. Side effect of above change to
+ declare_internal
+
+subst.c
+ - shell_expand_word_list: handle the W_ASSNGLOBAL flag and put -g into
+ the list of options passed to make_internal_declare as appropriate.
+ Fix for bug reported by Tim Friske <me@timfriske.com>
+
+ 11/30
+ -----
+test.c
+ - unary_op: make sure -v and -n check that the variable is not marked
+ as invisible before calling var_isset. Fix for bug reported by Tim
+ Friske <me@timfriske.com>
+
+ 12/2
+ ----
+subst.c
+ - process_substitute: turn off the `expanding_redir' flag, which
+ controls whether or not variables.c:find_variable_internal uses the
+ temporary environment to find variables. We want to use the
+ temp environment, since we don't have to worry about order of
+ evaluation in a subshell. Fixes bug reported by Andrey Borzenkov
+ <arvidjaar@gmail.com>
+
+ 12/4
+ ----
+lib/glob/glob.c
+ - glob_filename: changes to avoid null filenames and multiple entries
+ returned for patterns like **/** (globstar enabled). Fixes bug
+ reported by Ulf Magnusson <ulfalizer@gmail.com>
+
+ 12/10
+ -----
+lib/glob/glob.c
+ - glob_filename: finish up a series of changes to make globstar-style
+ globbing more efficient, avoid more duplicate filenames, and be more
+ compatible with other shells that implement it
+ o collapse a sequence of **/**/** to one **
+ o note when the directory name is all ** or ends in ** so we
+ can treat it specially when the filename is **
+ All inspired by report from Andrey Borzenkov <arvidjaar@gmail.com>
+
+lib/sh/zread.c
+ - zreadn: new function, like zread, but takes an additional argument
+ saying how many bytes to read into the local buffer. Can be used to
+ implement `read -N' without so many one-byte calls to zreadc. Code
+ from Mike Frysinger <vapier@gentoo.org>
+
+ 12/12
+ -----
+lib/glob/sm_loop.c
+ - PATSCAN (glob_patscan): if passed string already points to end of
+ pattern, return NULL immediately. Fixes problem with
+ extglob_skipname reported by Raphaël Droz <raphael.droz@gmail.com>
+
+ 12/13
+ -----
+execute_cmd.c
+ - execute_coproc: handle the command's exit status being inverted
+ (an oversight). Fixes bug reported by DJ Mills
+ <danielmills1@gmail.com> and Andreas Schwab <schwab@linux-m68k.org>
+
+ 12/14
+ -----
+lib/readline/readline.c
+ - bind_arrow_keys_internal: add MINGW key bindings for Home, End,
+ Delete, and Insert keys. Fix from Pierre Muller
+ <pierre.muller@ics-cnrs.unistra.fr>
+
+builtins/printf.def
+ - printf_builtin: '%()T' conversion: if there is no argument supplied,
+ behave as if -1 had been supplied (current time). ksh93-like feature
+ suggested by Clark Wang <dearvoid@gmail.com>
+
+doc/{bash.1,bashref.texi}
+ - document new printf %()T default argument behavior
+
+ 12/15
+ -----
+lib/readline/display.c
+ - displaying_prompt_first_line: new variable, indicates whether or
+ not the first line of output is displaying the prompt. Always true
+ in normal mode, sometimes false in horizontal scrolling mode
+ - rl_redisplay: set displaying_prompt_first_line to true unless we
+ are in horizontal mode; set to false in horizontal mode if the left
+ margin of the displayed line is greater than the end of the prompt
+ string
+ - rl_redisplay: when in horizontal scroll mode, don't adjust
+ _rl_last_c_pos by the wrap offset unless the line is displaying
+ a prompt containing invisible chars
+ - update line: don't adjust _rl_last_c_pos by the wrap offset unless
+ the line is displaying a prompt containing invisible chars
+ - update_line: if shrinking the line by reducing the number of
+ displayed characters, but we have already moved the cursor to the
+ beginning of the line where the first difference starts, don't
+ try to delete characters
+
+builtins/read.def
+ - unbuffered_read: set to 2 if invoked as `read -N'
+ - if unbuffered_read is set to 2, compute the number of chars we
+ need to read and read that many with zreadn. Posix mode still
+ uses zreadintr. Code from Mike Frysinger <vapier@gentoo.org>
+
+doc/{bash.1,bashref.texi}
+ - read: make it clear that if read times out, it saves any input
+ read to that point into the variable arguments. Report from
+ Fiedler Roman <Roman.Fiedler@ait.ac.at>
+
+subst.c
+ - command_substitute: change direct assignment of exit_immediately_on_error
+ to use change_flag ('e', FLAG_OFF) instead
+
+flags.c
+ - use errexit_flag as the variable modified by changes to the -e
+ option, reflect those changes to exit_immediately_on_error
+
+execute_cmd.c
+ - execute_builtin: new global variable, builtin_ignoring_errexit, set
+ to 0 by default and set to 1 if eval/source/command executing in a
+ context where -e should be ignored
+ - execute_builtin: set exit_immediately_on_error to errextit_flag
+ after executing eval/source/command in a context where -e should
+ be ignored
+
+flags.c
+ - if builtin_ignoring_errexit is set, changes to errexit_flag are
+ not reflected in the setting of exit_immediately_on_error. Fixes
+ bug reported by Robert Schiele <rschiele@gmail.com>
+
+ 12/23
+ -----
+include/posixjmp.h
+ - setjmp_nosigs: new define, call setjmp in such a way that it will
+ not manipulate the signal mask
+
+{expr,test,trap}.c
+ - setjmp_nosigs: call instead of setjmp; don't need to manipulate
+ signal mask
+
+builtins/read.def
+ - read_builtin: setjmp_nosigs: call instead of setjmp; don't need
+ to manipulate signal mask
+
+builtins/evalstring.c:
+ - parse_and_execute: setjmp_nosigs: call instead of setjmp; don't need
+ to manipulate signal mask
+ - parse_string: setjmp_nosigs: call instead of setjmp; don't need
+ to manipulate signal mask
+ - parse_and_execute: save and restore the signal mask if we get a
+ longjmp that doesn't cause us to return or exit (case DISCARD)
+
+ 12/24
+ -----
+general.c
+ - bash_tilde_expand: only set interrupt_immediately if there are no
+ signals trapped; we want to jump to top level if interrupted but
+ not run any trap commands
+
+ 12/25
+ -----
+jobs.c
+ - run_sigchld_trap: no longer set interrupt_immediately before calling
+ parse_and_execute, even if this is no longer run in a signal handler
+ context
+
+input.c
+ - getc_with_restart: add call to QUIT instead of CHECK_TERMSIG
+
+parse.y
+ - yy_stream_get: now that getc_with_restart calls QUIT, don't need to
+ set interrupt_immediately (already had call to run_pending_traps)
+
+execute_cmd.c
+ - execute_subshell_builtin_or_function,execute_function,execute_in_subshell:
+ setjmp_nosigs: call instead of setjmp when saving return_catch; don't
+ need to manipulate signal mask
+ - execute_subshell_builtin_or_function,execute_in_subshell:
+ setjmp_nosigs: call instead of setjmp where appropriate when saving
+ top_level; don't need to manipulate signal mask if we're going to
+ exit right away
+
+subst.c
+ - command_substitute: setjmp_nosigs: call instead of setjmp when saving
+ return_catch; don't need to manipulate signal mask
+ - command_substitute: setjmp_nosigs: call instead of setjmp where
+ appropriate when saving top_level; don't need to manipulate signal
+ mask if we're going to exit right away
+
+trap.c
+ - run_exit_trap: setjmp_nosigs: call instead of setjmp when saving
+ return_catch; don't need to manipulate signal mask
+ - run_exit_trap: setjmp_nosigs: call instead of setjmp where
+ appropriate when saving top_level; don't need to manipulate signal
+ mask if we're going to exit right away
+ - _run_trap_internal: setjmp_nosigs: call instead of setjmp when saving
+ return_catch; don't need to manipulate signal mask
+
+builtins/evalfile.c
+ - _evalfile: setjmp_nosigs: call instead of setjmp when saving
+ return_catch; don't need to manipulate signal mask
+
+builtins/evalstring.c
+ - evalstring: setjmp_nosigs: call instead of setjmp when saving
+ return_catch; don't need to manipulate signal mask
+
+shell.c
+ - main: setjmp_nosigs: call instead of setjmp where appropriate when
+ saving top_level; don't need to manipulate signal mask if we're
+ going to exit right away
+ - run_one_command: setjmp_nosigs: call instead of setjmp where
+ appropriate when saving top_level; don't need to manipulate signal
+ mask if we're going to exit right away
+ - run_wordexp: setjmp_nosigs: call instead of setjmp where
+ appropriate when saving top_level; don't need to manipulate signal
+ mask if we're going to exit right away
+
+eval.c
+ - reader_loop: save and restore the signal mask if we get a longjmp
+ that doesn't cause us to return or exit (case DISCARD)
+
+ 12/26
+ -----
+parse.y
+ - shell_input_line_{index,size,len}: now of type size_t; in some cases
+ the unsigned property makes a difference
+ - STRING_SAVER: saved_line_{size,index} now of type size_t
+ - shell_getc: don't allow shell_input_line to grow larger than SIZE_MAX;
+ lines longer than that are truncated until read sees a newline;
+ addresses theoretical buffer overflow described by Paul Eggert
+ <eggert@cs.ucla.edu>
+ - set_line_mbstate: size_t changes like shell_getc
+ - shell_getc: if shell_input_line is larger than 32K, free it and
+ start over to avoid large memory allocations sticking around
+
+variables.c
+ - bind_global_variable: new function, binds value to a variable in
+ the global shell_variables table
+
+variables.h
+ - bind_global_variable: new extern declaration
+
+builtins/declare.def
+ - declare_internal: if -g given with name=value, but variable is not
+ found in the global variable table, make sure to call
+ bind_global_variable so the variable is created and modified at
+ global scope. Fixes a bug where declare -g x=y could modify `x'
+ at a previous function scope
+
+command.h
+ - W_ASSIGNARRAY: new word flag, compound indexed array assignment
+
+subst.h
+ - ASS_MKGLOBAL: new assignment flag, forcing global assignment even in
+ a function context, used by declare -g
+
+execute_cmd.c
+ - fix_assignment_words: set W_ASSIGNARRAY flag if -a option given to
+ declaration builtin
+
+subst.c
+ - do_assignment_internal: explicitly handle case where we are
+ executing in a function and we want to create a global array or
+ assoc variable
+ - shell_expand_word_list: call make_internal_declare if -a option
+ given to declaration builtin (W_ASSIGNARRAY); handle -g option with
+ it (W_ASSNGLOBAL). Fixes inconsistency noticed by Vicente Couce
+ Diaz <vituko@gmail.com>, where declare -ag foo=(bar) could modify
+ array variable foo at previous function scope, not global scope
+
+ 12/27
+ -----
+bashline.c
+ - Minix needs the third argument to tputs to be a void funtion taking
+ an int argument, not an int-returning function. Fix from
+ John E. Malmberg <wb8tyw@qsl.net> as part of VMS bash port
+
+ 12/29
+ -----
+configure.ac,version.c,patchlevel.h
+ - bash-4.3-devel: new version, new shell compatibility level (43)
+
+subst.c
+ - parameter_brace_patsub: put the bash-4.2 code back in from the
+ change of 3/3 that runs the replacement string through quote
+ removal, make it dependent on shell_compatibility_level <= 42
+
+builtins/shopt.def
+ - compat42: new shopt option
+ - set_compatibility_level: change logic to set and unset various
+ compat variables and shell_compatibility_level
+
+COMPAT
+ - new documentation for bash-4.3 compatibility changes
+
+doc/{bash.1,bashref.texi}
+ - compat42: document new shopt option
+
+builtins/shopt.def
+ - set_compatibility_opts: new function, sets the various shopt
+ compat variables based on the value of shell_compatibility_level
+
+builtins/common.h
+ - set_compatibility_opts: new extern declaration
+
+variables.c
+ - BASH_COMPAT: new special variable; sets the shell compatibility
+ level. Accepts values in decimal (4.2) or integer (42) form;
+ Unsetting variable, setting it to empty string, or setting it to
+ out-of-range value sets the shell's compatibility level to the
+ default for the current version. Valid values are 3.1/31 through
+ the current version
+ - sv_shcompat: new function implementing logic for BASH_COMPAT
+
+variables.h
+ - sv_shcompat: new extern declaration
+
+doc/{bash.1,bashref.texi}
+ - BASH_COMPAT: description of new variable
+
+lib/readline/complete.c
+ - _rl_colored_stats: default back to 0 for 4.3 release branch
+
+ 1/5/2013
+ --------
+quit.h
+ - remove spurious call to itrace in CHECK_WAIT_INTR
+
+bashline.c
+ - bash_event_hook: if we're going to jump to top_level, make sure we
+ clean up after readline() by calling rl_cleanup_after_signal().
+ Fixes bug reported against devel branch by Raphaël Droz
+ <raphael.droz@gmail.com>
+ - bash_event_hook: reset the event hook before checking for signals
+ or traps in case we longjmp
+
+doc/{bash.1,bashref.texi}
+ - small additions to the set -e section to make it more clear that
+ contexts where -e is ignored extend to compound commands as well
+ as shell functions
+
+lib/readline/readline.h
+ - rl_signal_event_hook: new extern declaration
+
+lib/readline/input.c
+ - rl_signal_event_hook: new variable, hook function to call when a
+ function (currently just read(2)) is interrupted by a signal and
+ not restarted
+ - rl_getc: call rl_signal_event_hook instead of rl_event_hook
+
+lib/readline/doc/rltech.texi
+ - rl_signal_event_hook: document new function
+
+bashline.c
+ - changes to set rl_signal_event_hook instead of rl_event_hook
+
+lib/readline/readline.h
+ - change readline version numbers to 6.3
+
+ 1/6
+ ---
+doc/{bash.1,bashref.texi}
+ - a couple of changes to the descriptions of the ERR trap and its
+ effects based on a message from Rob Nagler <nagler@bivio.biz>
+
+ 1/9
+ ---
+expr.c
+ - expassign: invalidate curlval before freeing and NULLing tokstr to
+ avoid aliasing issues. Fixes bug reported by Eduardo A. Bustamante
+ López<dualbus@gmail.com> and Dan Douglas <ormaaj@gmail.com>
+
+braces.c
+ - array_concat: don't be so aggressive in trying to short-circuit. We
+ can only short-circuit if we have a single-element array where the
+ element is an empty string (array[0] == "" array[1] = 0x0). Existing
+ practice requires us to replicate arrays and prefix or append empty
+ strings. Fixes bug reported by Eduardo A. Bustamante López
+ <dualbus@gmail.com>
+
+ 1/11
+ ----
+execute_cmd.c
+ - execute_builtin: since mapfile uses evalstring() to run its callbacks
+ internally, just like eval, so it needs to handle the case where the
+ temp environment given to mapfile persists throughout the entire
+ set of callback commands. This might be a problem with trap also, but
+ trap isn't run in the same way. Fixes bug reported by Dan Douglas
+ <ormaaj@gmail.com>
+
+ 1/13
+ ----
+redir.c
+ - redirection_error: before expanding the redirection word (if
+ expandable_redirection_filename returns true), disable command
+ substitution during expansion. Fixes bug reported by Dan Douglas
+ <ormaaj@gmail.com>
+
+subst.c
+ - expand_word_internal: case '\\': if the next character is an IFS
+ character, and the expansion occurs within double quotes, and the
+ character is not one for which backslash retains its meaning, add
+ the (escaped) '\' and the (escaped) character. Fixes bug reported
+ by Dan Douglas <ormaaj@gmail.com>
+
+ 1/15
+ ----
+builtins/cd.def
+ - cd_builtin: make sure call to internal_getopt handles -e option.
+ Fixes bug reported by <mashimiao.fnst@cn.fujitsu.com>
+
+ 1/17
+ ----
+subst.c
+ - expand_word_list_internal: make sure tempenv_assign_error is
+ initialized to 0
+
+execute_cmd.c
+ - execute_simple_command: make sure tempenv_assign_error is reset to 0
+ after it's tested to see if an error should force the shell to exit.
+ Fixes problem where a the failure of a tempenv assignment preceding
+ a non-special builtin `sticks' and causes the next special builtin
+ to exit the shell. From a discussion on bug-bash started by
+ douxin <wq-doux@cn.fujitsu.com>
+
+ 1/20
+ ----
+subst.c
+ - parameter_brace_expand_rhs: call stupidly_hack_special_variables
+ after assigning with ${param[:]=word} even if IFS is changing.
+ Suggested by Dan Douglas <ormaaj@gmail.com> [TENTATIVE, needs work
+ on IFS side effects]
+
+command.h
+ - W_GLOBEXP (which was unused) is now W_SPLITSPACE (which isn't used
+ yet)
+
+{execute_cmd,subst,variables}.c
+ - removed all code that mentioned W_GLOBEXP
+ - removed mention of gnu_argv_flags and code that set it
+
+ 1/22
+ ----
+subst.c
+ - param_expand: set W_SPLITSPACE if we expand (unquoted) $* and
+ IFS is unset or null so we can be sure to split this on spaces
+ no matter what happens with IFS later
+ - expand_word_internal: note that param_expand returns W_SPLITSPACE
+ in the returned word flags and keep track of that state with
+ `split_on_spaces'
+
+ 1/23
+ ----
+subst.c
+ - expand_word_internal: if split_on_spaces is non-zero, make sure
+ we split `istring' on spaces and return the resultant word. The
+ previous expansions should have quoted spaces in the positional
+ parameters where necessary. Suggested by Dan Douglas
+ <ormaaj@gmail.com>
+
+execute_cmd.c
+ - execute_command_internal: make sure any subshell forked to run a
+ group command or user subshell at the end of a pipeline runs any
+ EXIT trap it sets. Fixes debian bash bug 698411
+ http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=698411
+
+subst.c
+ - shell_expand_word_list: fix code that creates args for and calls
+ make_internal_declare to avoid calling it twice (missing `else'
+ in 12/26 change)
+ - do_assignment_internal: fix code from 12/26 change to fix problem
+ where an existing assoc variable could be converted to an array
+ without checking `mkassoc'
+
+ 1/24
+ ----
+builtins/evalfile.c
+ - _evalfile: add missing `close (fd)' calls before returning to
+ avoid fd leaks. Bug and fix from Roman Rakus <rrakus@redhat.com>
+
+ 1/25
+ ----
+builtins/read.def
+ - read_builtin: don't try to play tricks with the top of the unwind-
+ protect stack after read gets a SIGALRM; save input_string to new
+ memory, run the stack, then restore input_string and assign the
+ variables. Part of fix for bug reported by konsolebox
+ <konsolebox@gmail.com>; the rest of the fix is with the changes in
+ trap and signal handling and doing away with interrupt_immediately
+
+ 1/26
+ ----
+redir.c
+ - redirection_expand, write_here_string, write_here_document: before
+ calling any of the word expansion functions, after setting
+ expanding_redir to 1 (which bypasses the temp environment in the
+ variable lookup functions), call sv_ifs to reset the cached IFS-
+ related variables set by subst.c:setifs(). This ensures that
+ redirections will not get any IFS values that are set in the
+ temporary environment, as Posix specifies. Then, after the word
+ expansions, after resetting expanding_redir to 0, call sv_ifs
+ again to make sure the cached IFS values are set from any
+ assignments in the temporary environment. We force executing_builtin
+ to 1 to `fool' the variable lookup functions into using any temp
+ environment, then reset it to its old value after sv_ifs returns.
+ This is what allows read() to use the (cached) IFS variables set
+ in the temp environment. Fixes inconsistency reported by Dan Douglas
+ <ormaaj@gmail.com>
+
+ 1/29
+ ----
+lib/readline/display.c
+ - update_line: fix off-by-one error when updating vis_lbreaks array
+ in a multibyte locale that occurs when moving multibyte chars from
+ one line down to another. Bug report and fix from Egmont
+ Koblinger <egmont@gmail.com>
+
+ 1/30
+ ----
+configure.ac
+ - changed version to 4.3-alpha
+
+redir.c
+ - redir_open: handle open returning -1/EINTR, which seems to happen
+ a lot with FIFOs and SIGCHLD, and call QUIT to handle other
+ signals that can interrupt open(2). Bug report and initial fix
+ from Mike Frysinger <vapier@gentoo.org>
+
+ 1/31
+ ----
+subst.c
+ - parameter_brace_expand: make sure to propagate the PF_ASSIGNRHS flag
+ to parameter_brace_expand_word
+ - parameter_brace_expand_word: make sure that if the PF_ASSIGNRHS flag
+ is set and we are expanding ${a[@]} or ${a[*]} we set quoted to
+ include Q_DOUBLE_QUOTES before calling array_value_internal, mirroring
+ what we do for $@ and $*. Fixes inconsistency reported by Dan
+ Douglas <ormaaj@gmail.com>
+
+configure.ac
+ - use AC_CHECK_TOOL instead of AC_CHECK_PROG to check for ar, since it
+ will find $host-prefixed versions of utilities. Report and fix from
+ Mike Frysinger <vapier@gentoo.org>
+
+builtins/setattr.def
+ - set_var_attribute: check whether bind_variable (called when the
+ variable whose attributes are being modified is found in the temp
+ environment) just modified a read-only global variable, and don't
+ bother marking the temporary variable for propagation if so. The
+ propagation is superfluous and will result in a strange error
+ message
+
+ 2/2
+ ---
+variables.c
+ - initialize_shell_variables: don't try to import function definitions
+ with invalid names from the environment if already in posix mode,
+ but create them as (invisible) exported variables so they pass
+ through the environment. Print an error message so user knows
+ what's wrong. Fixes bug reported by Tomas Trnka <ttrnka@mail.muni.cz>
+
+ 2/9
+ ---
+
+builtins/read.def
+ - sigalrm_seen, alrmbuf: now global so the rest of the shell (trap.c)
+ can use them
+ - sigalrm: just sets flag, no longer longjmps to alrmbuf; problem was
+ longjmp without manipulating signal mask, leaving SIGALRM blocked
+
+quit.h
+ - move CHECK_ALRM macro here from builtins/read.def so trap.c:
+ check_signals() can call it
+
+trap.c
+ - check_signals: add call to CHECK_ALRM before QUIT
+ - check_signals_and_traps: call check_signals() instead of including
+ CHECK_ALRM and QUIT inline. Integrating check for read builtin's
+ SIGALRM (where zread call to check_signals_and_traps can see it)
+ fixes problem reported by Mike Frysinger <vapier@gentoo.org>
+
+ 2/12
+ ----
+lib/glob/xmbsrtowcs.c
+ - xdupmbstowcs2: fixed but where end of string was not handled
+ correctly, causing loop to go past end of string in a bunch of cases.
+ Fixes bug reported by "Dashing" <dashing@hushmail.com>
+
+
+ 2/13
+ ----
+builtins/pushd.def
+ - popd_builtin: treat any argument that isn't -n or of the form
+ [-+][[:digit:]]* as an error. Fixes problem reported by Bruce
+ Korb <bruce.korb@gmail.com>
+
+ 2/14
+ ----
+configure.ac
+ - add check for sig_atomic_t; already a placeholder for it in
+ config.h.in
+
+ 2/15
+ ----
+subst.c
+ - do_compound_assignment: don't call assign_compound_array_list with
+ a NULL variable in case make_local_xxx_variable returns NULL
+ (it will if you try to shadow a readonly or noassign variable).
+ Fixes bug reported by Richard Tollerton <rich.tollerton@ni.com>
+
+ 2/16
+ ----
+variables.c
+ - make_local_variable: print error messager if an attempt is made to
+ create a local variable shadowing a `noassign' variable. Previously
+ we just silently refused to do it
+
+trap.[ch]
+ - get_original_signal: now global so rest of the shell can use it
+
+sig.c
+ - initialize_shell_signals: install a signal handler for SIGTERM
+ that does nothing except set a sigterm_received flag instead of
+ ignoring it with SIG_IGN, as long as SIGTERM is not ignored when
+ the shell is started. Use get_original_signal early to get the
+ original handler, since we will do that later anyway
+ - set_signal_handler: if installing sigterm_sighandler as the SIGTERM
+ handler, make sure to add SA_RESTART flag to make it as close to
+ SIG_IGN as possible
+
+sig.h
+ - sigterm_sighandler: new extern declaration
+
+quit.h
+ - RESET_SIGTERM: set sigterm_receved to 0
+ - CHECK_SIGTERM: check sigterm_received; if it's non-zero, treat it
+ as a fatal signal and call termsig_handler to exit the shell
+
+jobs.c
+ - make_child: call RESET_SIGTERM just before fork() so we can detect
+ if the child process received a SIGTERM before it's able to change
+ the signal handler back to what it was when the shell started
+ (presumably SIG_DFL). Only has effect if the shell installed
+ sigterm_sighandler for SIGTERM, interactive shells that were not
+ started with SIG_IGN as the SIGTERM handler
+ - make_child: call RESET_SIGTERM in the parent after fork() so the
+ rest of the shell won't react to it
+
+execute_cmd.c
+ - execute_simple_command: call CHECK_SIGTERM after make_child in child
+ to catch SIGTERM received after fork() and before restoring old
+ signal handlers
+ - execute_disk_command: call CHECK_SIGTERM after make_child in child
+ process after restoring old signal handlers and again just before
+ calling shell_execve. Fixes race condition observed by
+ Padraig Brady <p@draigbrady.com> when testing with his `timeout'
+ program
+
+lib/readline/display.c
+ - open_some_spaces: new function, subset of insert_some_chars that just
+ opens up a specified number of spaces to be overwritten
+ - insert_some_spaces: now just calls to open_some_spaces followed by
+ _rl_output_some_chars
+ - update_line: use col_temp instead of recalculating it using
+ _rl_col_width in the case where we use more columns with fewer bytes
+ - update_line: use open_some_spaces and then output the right number
+ of chars instead of trying to print new characters then overwrite
+ existing characters in two separate calls. This includes removing
+ some dodgy code and making things simpler. Fix from Egmont
+ Koblinger <egmont@gmail.com>
+ - use new variable `bytes_to_insert' instead of overloading temp in
+ some code blocks (nls - nfd, bytes that comprise the characters
+ different in the new line from the old)
+
+ 2/18
+ ----
+redir.c
+ - do_redirection_internal: add undoable redirection for the implicit
+ close performed by the <&n- and >&n- redirections. Fixes bug
+ reported by Stephane Chazelas <stephane.chazelas@gmail.com>
+
+ 2/19
+ ----
+sig.c
+ - termsig_handler: an interactive shell killed by SIGHUP and keeping
+ command history will try to save the shell history before exiting.
+ This is an attempt to preserve the save-history-when-the-terminal-
+ window-is-closed behavior
+
+ 2/21
+ ----
+braces.c
+ - brace_expand: if a sequence expansion fails (e.g. because the
+ integers overflow), treat that expansion as a simple string, including
+ the braces, and try to process any remainder of the string. The
+ remainder may include brace expansions. Derived from SuSE bug
+ 804551 example (https://bugzilla.novell.com/show_bug.cgi?id=804551)
+
+ 2/23
+ ----
+{quit,sig}.h,sig.c
+ - sigterm_received declaration now in sig.h; type is sig_atomic_t
+ - sigwinch_received type now sig_atomic_t
+ - sig.h includes bashtypes.h and <signal.h> if SIG_DFL not defined
+ (same logic as trap.h) to pick up sig_atomic_t
+
+unwind_prot.c
+ - include sig.h before quit.h (reverse order)
+
+ 2/27
+ ----
+builtins/shopt.def
+ - reset_shopt_options: make sure check_window_size is reset to the
+ default from config.h, not unconditionally to 0
+
+jobs.[ch]
+ - last_made_pid, last_asynchronous_pid: now volatile. Change from SuSE
+
+jobs.c
+ - wait_for: if we're using sigaction to install a handler for SIGCHLD,
+ make sure we specify SA_RESTART
+
+lib/{tilde,readline}/shell.c
+ - get_home_dir: instead of looking in the password file every time,
+ look once and cache the result
+
+sig.[ch]
+ - sigwinch_received, sigterm_received: now `volatile' qualified
+
+sig.c,quit.h
+ - interrupt_state,terminating_signal: now sig_atomic_t
+
+ 3/1
+ ---
+MANIFEST,examples/*
+ - removed around 120 files without FSF copyrights; requested by
+ Karl Berry in early January
+
+ 3/2
+ ---
+lib/malloc/malloc.c
+ - morecore: only check whether SIGCHLD is trapped if SIGCHLD is defined
+
+doc/bashref.texi
+ - Fixed most of the examples in the GNU Parallel section to use better
+ shell idioms following complaints on bug-bash; added a couple of
+ examples and smoothed out the text
+
+quit.h
+ - include "sig.h" for sig_atomic_t
+
+lib/readline/display.c
+ - update_line: when inserting one or more characters at the end of
+ the display line in a non-multibyte environment, just write from the
+ first difference to the end of the line and return. We don't have
+ to adjust _rl_last_c_pos. This is needed to adjust from the old
+ two-part copy to a single call to _rl_output_some_chars (change of
+ 2/16)
+
+ 3/4
+ ---
+Makefile.in,doc/Makefile.in
+ - PACKAGE_TARNAME, docdir: new variables substituted by autoconf
+ - OTHER_DOCS,OTHER_INSTALLED_DOCS: new variables with auxiliary
+ documentation files to be installed into $(docdir)
+ - install: add new rule to install $(OTHER_DOCS)
+ - uninstall: add new rule to uninstall $(docdir)/$(OTHER_INSTALLED_DOCS)
+
+doc/bash.1
+ - add URL to `POSIX' file in `SEE ALSO' section; put pointer to that
+ section in --posix and set -o posix descriptions
+
+examples/
+ - removed around 110 examples at the request of the FSF due to copyright
+ issues
+
+ 3/5
+ ---
+builtins/setattr.def
+ - readonly: modified help text slightly to make it clearer that
+ functions aren't changed or displayed unless the -f option is given.
+ Report from <gotmynick@gmail.com>
+
+ 3/9
+ ---
+include/typemax.h
+ - SIZE_MAX: define to 65535 (Posix minimum maximum) if not defined
+
+parse.y
+ - include "typemax.h" for possible SIZE_MAX definition, make sure we
+ include it after shell.h
+
+{braces,expr}.c
+ - include "typemax.h" for possible INTMAX_MIN and INTMAX_MAX definitions
+
+ 3/10
+ ----
+bashline.c
+ - bash_default_completion: make sure completion type of `!' (same as
+ TAB but with show-all-if-ambiguous set) and glob-word-completion
+ sets rl_filename_completion_desired to 0 so extra backslashes don't
+ get inserted by `quoting' the completion. We can't kill all the
+ matches because show-all-if-ambiguous needs them. Bug report from
+ Marcel (Felix) Giannelia <info@skeena.net>
+
+[bash-4.3-alpha frozen]
+
+ 3/14
+ ----
+general.c
+ - trim_pathname: use memmove instead of memcpy since the source and
+ destination pathnames may overlap. Report and fix from Matthew
+ Riley <mattdr@google.com>
+
+ 3/18
+ ----
+configure.ac
+ - socklen_t is defined as `unsigned int' if configure can't find it
+
+ 3/20
+ ----
+lib/readline/complete.c
+ - S_ISVTX: since it's not defined on all platforms (Minix), make sure
+ its use is protected with #ifdef
+
+ 3/21
+ ----
+doc/{bash.1,bashref.texi}
+ - Added mention of ${!name[@]} and ${!name[*]} expansions to get all
+ indices of an array. Suggested by Jonathan Leffler
+ <jonathan.leffler@gmail.com>
+
+ 3/24
+ ----
+subst.h
+ - SD_IGNOREQUOTE: new define for skip_to_delim; if set, means that
+ single quotes (for now) will be treated as ordinary characters
+
+subst.c
+ - skip_to_delim: handle SD_IGNOREQUOTE. no callers use it for now
+
+ 3/25
+ ----
+support/config.{guess,sub}
+ - updated to versions from autoconf-2.69
+
+ 3/31
+ ----
+lib/sh/shquote.c
+ - sh_single_quote: short-circuit quoting a single "'" instead of
+ creating a long string with empty single-quoted strings
+
+parser.h
+ - DOLBRACE_QUOTE2: new define, like DOLBRACE_QUOTE, but need to single-
+ quote results of $'...' expansion because quote removal will be
+ done later. Right now this is only done for ${word/pat/rep}
+
+parse.y
+ - parse_matched_pair: set state to DOLBRACE_QUOTE2 for pattern
+ substitution word expansion so we don't treat single quote specially
+ in the pattern or replacement string
+ - parse_matched_pair: if we're parsing a dollar-brace word expansion
+ (${...}) and we're not treating single quote specially within
+ double quotes, single-quote the translation of $'...' ansi-c
+ escaped strings. Original report and fix from Eduardo A.
+ Bustamante López <dualbus@gmail.com>
+
+subst.c
+ - extract_dollar_brace_string: ${word/pat/rep} scanning now sets the
+ DOLBRACE_QUOTE2 flag instead of DOLBRACE_QUOTE so we don't treat
+ single quotes specially within a double-quoted string
+
+execute_cmd.c
+ - fix_assignment_words: skip over assignment statements preceding a
+ command word before trying to figure out whether or not assignment
+ statements following a possible declaration command should be
+ treated specially. Fixes bug reported by Dan Douglas
+ <ormaaj@gmail.com>
+
+ 4/4
+ ---
+lib/readline/readline.c
+ - _rl_dispatch_subseq: only call _rl_vi_set_last (and check whether
+ the key is a text modification command) if the key sequence length
+ is 1. That keeps the arrow keys from setting the last command
+ when called in vi command mode. Fixes bug reported by Ian A.
+ Watson <watson_ian_a@lilly.com>
+
+ 4/6
+ ---
+lib/readline/bind.c
+ - rl_parse_and_bind: when parsing a double-quoted string as the value
+ of a variable, make sure we skip past the leading double quote.
+ Fix from Andreas Schwab <schwab@linux-m68k.org>
+
+variables.c
+ - hash_lookup: set new local variable last_table_searched to the table
+ a successful lookup appears in; tested in make_local_variable to
+ solve the problem below
+ - make_local_variable: if we find a variable with the tempenv flag
+ set at the same `level' as variable_context', but not found in the
+ temporary_env (temp environment preceding the builtin), return it.
+ The temp environment preceding the function call has already been
+ merged (in execute_function) into the list of variable contexts the
+ function sees as shell_variables by the time this is called. Fixes
+ inconsistency pointed out by Dan Douglas <ormaaj@gmail.com>
+
+subst.c
+ - expand_arith_string: expanded out contents of expand_string,
+ expand_string_internal, expand_string_if_necessary to create a
+ WORD_DESC and call call_expand_word_internal() on it directly.
+ We don't want process substitution to be performed ( 1<(2) ) should
+ mean something different in an arithmetic expression context.
+ It doesn't work to just turn on the DQUOTE flag, since that means
+ that things like ${x["expression"]} are not expanded correctly.
+ Fixes problem pointed out by Dan Douglas <ormaaj@gmail.com>
+
+ 4/13
+ ----
+subst.c
+ - process_substitute: run the EXIT trap before exiting, as other
+ shells seem to. Fixes problem pointed out by Dan Douglas
+ <ormaaj@gmail.com>
+
+lib/readline/readline.c
+ - readline_internal_setup: call rl_vi_insertion_mode to enter vi
+ mode instead of rl_vi_insert_mode to avoid resetting the saved last
+ command information. Posix says that `.' can repeat a command
+ that was entered on a previous line so we need to save the info.
+ Fixes bug reported by Ian A. Watson <watson_ian_a@lilly.com>
+
+ 4/14
+ ----
+lib/readline/complete.c
+ - rl_completion_matches: make sure xrealloc returns something non-null
+ (can happen when interrupted by a signal) before trying to add
+ matches to match_list
+
+subst.c
+ - array_remove_pattern: return NULL right away if array_variable_part
+ returns an invisible variable
+ - array_length_reference: handle array_variable_part returning an
+ invisible variable
+ - get_var_and_type: handle array_variable_part returning an invisible
+ variable
+
+ 4/15
+ ----
+execute_cmd.c
+ - execute_command_internal: make sure to run the EXIT trap for group
+ commands anywhere in pipelines, not just at the end. From a point
+ raised by Andreas Schwab <schwab@linux-m68k.org>
+
+variables.c
+ - bind_int_variable: make sure invisible flag is unset. Fixes problems
+ like "declare -ai a; : $(( a[4]=4 ));"
+
+arrayfunc.c
+ - array_variable_part: return variable even if invisible flag set,
+ callers must handle invisible vars
+
+ 4/18
+ ----
+builtins/set.def
+ - unset_builtin: if -n flag given, call unset_nameref instead of
+ unset_variable
+
+variables.c
+ - find_variable_nameref: print warning message if nameref circular
+ reference detected, return NULL and let caller deal with it
+
+builtins/declare.def
+ - declare_builtin: only disallow global references at this point if
+ we are at the global scope
+
+ 5/16
+ ----
+configure.ac
+ - update release status to beta
+
+ 5/23
+ ----
+trap.c
+ - run_pending_traps: save and restore pipeline around calls to
+ evalstring() in case we get a trap while running a trap. Have to
+ figure out the recursive running traps issue elsewhere. Fixes
+ bug reported by Roman Rakus <rrakus@redhat.com>
+ - run_pending_traps: make sure to set running_trap to the appropriate
+ signal value when running a trap command
+ - run_pending_traps: short-circuit immediately if running_trap set
+ when invoked. Could change this later to only skip if it would
+ run the same trap as currently being run (running_trap == sig + 1)
+
+configure.ac
+ - add warning if bison not found
+
+lib/readline/doc/rltech.texi
+ - new section with an example program illustrating the callback
+ interface. Suggested by Peng Yu <pengyu.ut@gmail.com>
+
+examples/loadables/Makefile.in
+ - remove references to `cut' and `getconf', which were removed in
+ early March
+
+ 5/28
+ ----
+lib/sh/pathphys.c
+ - sh_realpath: correct inverted two arguments to call to sh_makepath.
+ Report and fix from Julien Thomas <jthomas@exosec.fr>
+
+ 6/7
+ ---
+execute_cmd.c
+ - executing_line_number: the else clauses that are conditional on
+ various options being defined can simply be if clauses -- they are
+ mutually exclusive and all have `return' in the body. Fixes bug
+ reported by Flavio Medeiros <flaviomotamedeiros@gmail.com>
+
+ 6/25
+ ----
+lib/readline/readline.c
+ - readline_internal_setup: only sent the meta-key enable string to the
+ terminal if we've been told to use one and the terminal has been
+ successfully initialized (RL_ISSTATE (RL_STATE_TERMPREPPED) != 0).
+ Suggested by Dan Mick <dan.mick@inktank.com>
+
+lib/readline/signals.c
+ - _rl_signal_handler: call any defined signal hook after calling
+ rl_resize_terminal when handling a SIGWINCH. We already have called
+ the original SIGWINCH handler but will not be resending the signal
+ to ourselves
+
+ 6/27
+ ----
+lib/readline/doc/history.3, doc/bash.1
+ - fix description of the `$' modifier to note that it expands to the
+ last *word*, which is not always the last argument. Report from
+ ariyetz@gmail.com via gnu.org RT
+
+ 6/29
+ ----
+lib/glob/smatch.c
+ - glob_asciiranges: initialize to value of GLOBASCII_DEFAULT instead
+ of 0 (0 if not defined)
+
+configure.ac,config.h.in
+ - --enable-glob-asciiranges-default: new option, controls the value of
+ GLOBASCII_DEFAULT; use it to turn globasciiranges shopt option on
+ by default
+
+doc/bashref.texi
+ - document new --enable-glob-asciiranges-default configure option
+
+variables.c
+ - assign_in_env: implement += value appending semantics for assignments
+ preceding command names
+
+ 7/4
+ ---
+expr.c
+ - set lasttok = NUM in all of the functions that result in a number,
+ even if it's a boolean, to avoid errors with constructs like
+ 1 * x = 1, which should be an asignment error. Fixes problem
+ pointed out by Dan Douglas <ormaaj@gmail.com>
+
+parse.y
+ - decode_prompt_string: don't bother to call strcpy if
+ polite_directory_format returns its argument unchanged. It's not
+ necessary and Mac OS X 10.9 aborts because of a supposed overlapping
+ string copy. Bug and fix from simon@hitzemann.org
+
+subst.c
+ - parameter_brace_find_indir: new function, code from
+ parameter_brace_expand_indir that looks up the indirectly-referenced
+ variable, but does not expand it
+ - parameter_brace_expand_indir: call parameter_brace_find_indir to
+ look up indirected variable reference
+ - get_var_and_type: call parameter_brace_find_indir if it looks like we
+ are trying to manipulate an indirect variable reference like
+ ${!b%%foo}. This makes a difference if !b references an array
+ variable. Bug report from Dan Douglas <ormaaj@gmail.com>
+
+ 7/6
+ ---
+lib/sh/casemod.c
+ - sh_modcase: make sure argument passed to is_basic is <= UCHAR_MAX,
+ since cval can convert something to a wchar_t greater than UCHAR_MAX.
+ Fixes bug reported by Tomasz Tomasik <scx.mail@gmail.com>
+
+ 7/8
+ ---
+lib/readline/history.c
+ - add_history_time: if history_length == 0, referencing history_length
+ - 1 will result in an array bounds error, so make history_length be
+ at least 1 before going on. Fixes bug reported by Geng Sheng Liu
+ <gsliu.tju@gmail.com>
+
+builtins/setattr.def
+ - show_func_attributes: display definition (if NODEFS argument is 0) and
+ attributes for a particular function; used by `declare -fp name'
+
+builtins/declare.def
+ - declare_internal: call show_func_attributes if -f supplied with -p.
+ Fixes inconsistency observed by Linda Walsh <bash@tlinx.org>
+
+builtins/common.h
+ - new extern declaration for show_func_attributes
+
+builtins/read.def
+ - read_builtin: check the first supplied variable name for validity
+ before attempting to read any input, since we know we will have to
+ at least use that one. Don't check any other names yet. Suggested
+ by jidanni@jidanni.org
+
+ 7/10
+ ----
+redir.c
+ - do_redirection_internal: when closing a file descriptor with
+ r_close_this ([n]<&-) count close errors as redirection errors if
+ errno ends up as EIO or ENOSPC. Originally reported back in April
+ 2012 by Andrey Zaitsev <jstcdr@gmail.com>
+
+ 7/11
+ ----
+redir.c
+ - do_redirection_internal: before calling check_bash_input, make sure
+ that we don't call check_bash_input for an asynchronous process that
+ is replacing stdin with something else. The seek backwards affects
+ the parent process as well, since parents and children share the
+ file pointer. Fixes problem originally reported in March 2013 by
+ Martin Jackson <mjackson220.list@gmail.com>
+
+ 7/13
+ ----
+doc/{bash.1,bashref.texi}
+ - slight change to add a description of `shopt -o' suggested by Bruce
+ Korb <bruce.korb@gmail.com>
+
+ 7/19
+ ----
+lib/readline/histfile.c
+ - history_do_write: if close returns < 0, make sure we restore the
+ backup history file and return a non-zero value
+ - history_truncate_file: if write or close return < 0, make sure we
+ return a non-zero value
+
+[bash-4.3-beta frozen]
+
+ 7/21
+ ----
+lib/readline/isearch.c
+ - rl_display_search: now takes an entire search context flags word as
+ the second argument, instead of just reverse flag; changed callers
+ - rl_display_search: if the search has failed, add `failed ' to the
+ beginning of the search prompt
+ - _rl_isearch_dispatch: if the search has failed, display the entire
+ search string with an indication that the search failed but with the
+ last matching line. Suggested by jidanni@jidanni.org
+
+command.h
+ - W_ASSIGNINT: new word flag; used internally for make_internal_declare
+ and set by fix_assignment_words
+
+execute_cmd.c
+ - fix_assignment_words: set W_ASSIGNINT if compound assignment and -i
+ given as option. We don't do anything with the value yet
+
+subst.c
+ - shell_expand_word_list: rework the way the option list that is
+ passed to make_internal_declare is created
+
+ 8/1
+ ---
+doc/{bash.1,bashref.texi}
+ - minor changes to description of $! based on a report from Chris
+ Down <chris@chrisdown.name>
+
+arrayfunc.c
+ - assign_array_element_internal: before trying to get an array's max
+ index to process a negative subscript, make sure the array exists.
+ Bug report from Geir Hauge <geir.hauge@gmail.com>
+
+ 8/2
+ ---
+arrayfunc.c
+ - assign_array_element_internal: before using array_max_index() when
+ processing a negative subscript, make sure the variable is an array.
+ if it's not, use 0 as array_max_index assuming it's a string.
+ Fixes bug report from Geir Hauge <geir.hauge@gmail.com>
+
+ 8/3
+ ---
+Makefile.in
+ - pcomplete.o: add dependency on $(DEFDIR)/builtext.h. Suggested by
+ Curtis Doty <curtis@greenkey.net>
+
+ 8/5
+ ---
+lib/glob/sm_loop.c
+ - strcompare: short-circuit and return FNM_NOMATCH if the lengths of the
+ pattern and string (pe - p and se - s, respectively) are not equal
+ - strcompare: don't bother trying to set *pe or *se to '\0' if that's
+ what they already are. Fixes bug reported by Geir Hauge
+ <geir.hauge@gmail.com>
+
+ 8/6
+ ---
+doc/{bash.1,bashref.texi},builtins/hash.def,lib/readline/doc/rluser.texi
+ - minor typo changes from Geir Hauge <geir.hauge@gmail.com>
+
+bultins/help.def
+ - show_longdoc: avoid trying to translate the empty string because it
+ often translates to some boilerplate about the project and
+ translation. Report and fix from Geir Hauge <geir.hauge@gmail.com>
+
+ 8/8
+ ---
+builtins/help.def
+ - help_builtin: try two passes through the list of help topics for each
+ argument: one doing exact string matching and one, if the first pass
+ fails to find a match, doing string prefix matching like previous
+ versions. This prevents `help read' from matching both `read' and
+ `readonly', but allows `help r' to match everything beginning with
+ `r'. Inspired by report from Geir Hauge <geir.hauge@gmail.com>
+
+ 8/13
+ ----
+builtins/fc.def
+ - fc_builtin,fc_gethnum: calculate `real' end of the history list and
+ use it if -0 is specified as the beginning or end of the history
+ range to list. Doesn't work for fc -e or fc -s by design. Feature
+ requested by Mike Fied <micfied@gmail.com>
+
+ 8/16
+ ----
+trap.c
+ - _run_trap_internal: use {save,restore}_parser_state instead of
+ {save,restore}_token_state. It's more comprehensive
+
+ 8/23
+ ----
+doc/bash.1
+ - disown: remove repeated text. Report and fix from Thomas Hood
+ <jdthood@gmail.com>
+
+ 8/25
+ ----
+lib/readline/rltty.c
+ - set_special_char: fix prototype (last arg is rl_command_func_t *)
+
+sig.c
+ - set_signal_handler: return oact.sa_handler only if sigaction
+ succeeds; if it doesn't, return SIG_DFL (reasonable default). From
+ https://bugzilla.redhat.com/show_bug.cgi?id=911404
+
+bashline.c
+ - attempt_shell_completion: fix to skip assignment statements preceding
+ command name even if there are no programmable completions defined.
+ From https://bugzilla.redhat.com/show_bug.cgi?id=994659
+ - attempt_shell_completion: if still completing command word following
+ assignment statements, do command completion even if programmable
+ completion defined for partial command name entered so far
+
+ 8/26
+ ----
+pcomplete.c
+ - pcomp_filename_completion_function: make sure rl_filename_dequoting_function
+ is non-NULL before trying to call it. Bug and fix from
+ Andreas Schwab <schwab@linux-m68k.org>
+
+bashline.c
+ - bash_command_name_stat_hook: if *name is not something we're going
+ to look up in $PATH (absolute_program(*name) != 0), just call the
+ usual bash_filename_stat_hook and return those results. This makes
+ completions like $PWD/exam[TAB] add a trailing slash
+
+ 9/2
+ ---
+builtins/read.def
+ - read_builtin: before comparing what we read to the delim, make sure
+ we are not supposed to be ignoring the delimiter (read -N). We
+ set the delim to -1, but it's possible to read a character whose
+ int value ends up being between -1 and -128. Fixes bug
+ reported by Stephane Chazelas <stephane.chazelas@gmail.com>
+
+doc/{bash.1,bashref.texi}
+ - word splitting: crib some language from Posix to make it clear that
+ characters in IFS are treated as field *terminators*, not field
+ *separators*. Addresses issue raised by DJ Mills
+ <danielmills1@gmail.com>
+
+lib/readline/{util.c,rldefs.h}
+ - _rl_stricmp,_rl_strnicmp: now take const char * string arguments;
+ changed prototype declarations
+
+ 9/5
+ ---
+doc/{bash.1,bashref.texi}
+ - [[: modify description of pattern matching to make it clear that the
+ match is performed as if the extglob option were enabled. From Red
+ Hat bug https://bugzilla.redhat.com/show_bug.cgi?id=1002078
+
+ 9/12
+ ----
+lib/readline/isearch.c
+ - _rl_isearch_dispatch: if we read an ESC and it's supposed to
+ terminate the search, make sure we check for typeahead with
+ _rl_pushed_input_available, since installing a hook function causes
+ typeahead to be collected in `ibuffer' (input.c). If there is any,
+ make sure we still use the ESC as a prefix character. Bug and fix
+ from Mike Miller <mtmiller@ieee.org>
+
+ 9/16
+ ----
+builtins/{caller,cd,kill,pushd,wait}.def
+ - builtin_usage(): make sure call to this sets return status to
+ EX_USAGE
+
+ 9/18
+ ----
+terminal.c
+ - rl_change_environment: new application-settable variable; if non-
+ zero (the default), readline will modify LINES and COLUMNS in the
+ environment when it handles SIGWINCH
+ - _rl_get_screen_size: if rl_change_environment is non-zero, use setenv
+ to modify LINES and COLUMNS environment variables
+
+readline.h
+ - rl_change_environment: new extern declaration for applications
+
+ 9/22
+ ----
+configure.ac
+ - relstatus: bumped version to bash-4.3-beta2
+
+ 9/24
+ ----
+
+lib/readline/readline.c
+ - bind_arrow_keys_internal: added more key bindings for the numeric key
+ pad arrow keys on mingw32. Patch from Pierre Muller
+ <pierre.muller@ics-cnrs.unistra.fr>
+
+ 10/19
+ -----
+
+bashline.c
+ - maybe_restore_tilde: version of restore_tilde that honors `direxpand';
+ calls restore_tilde after saving directory expansion hook if
+ necessary. Report from Andreas Schwab <schwab@linux-m68k.org>
+
+builtins/cd.def
+ - -@: new option, allows cd to use `extended attributes' present in
+ NFSv4, ZFS; idea taken from ksh93. Attributes associated with a
+ file are presented as a directory containing the attributes as
+ individual files. Original patch contributed by Cedric Blancher
+ <cedric.blancher@gmail.com>
+
+ 10/20
+ -----
+aclocal.m4
+ - BASH_CHECK_MULTIBYTE: check for wcwidth being broken with unicode
+ combining characters needs a value to use when cross-compiling.
+ Bug report from Bert Sutherland <bertsutherland@gmail.com>
+
+doc/{bash.1,bashref.texi}
+ - document new -@ option to cd builtin
+
+ 10/28
+ -----
+lib/glob/{{gmisc,glob}.c,glob.h}
+ - extglob_pattern renamed to extglob_pattern_p, declared in glob.h
+
+subst.c
+ - expand_word_internal: typo fix: case to fix " $@\ " bug in bash-4.2
+ had a typo (& isexp instead of &&)
+
+ 10/29
+ -----
+input.c
+ - getc_with_restart: make sure local_index and local_bufused are
+ reset to 0 before returning EOF, in case we are running an interactive
+ shell without line editing and ignoreeof is set. Report and fix
+ from Yong Zhang <yong.zhang@windriver.com>
+
+lib/readline/search.c
+ - _rl_nsearch_init: take out extra third argument to rl_message; it
+ only matches prototype (and maybe format) in cases where
+ PREFER_STDARG and USE_VARARGS are both undefined, which is rare
+
+ 10/31
+ -----
+subst.c
+ - process_substitute: when opening the named pipe in the child, open
+ without O_NONBLOCK to avoid race conditions. Happens often on AIX.
+ Bug report and fix from Michael Haubenwallner
+ <michael.haubenwallner@salomon.at>
+
+builtins/ulimit.def
+ - RLIMIT_NTHR: if RLIMIT_PTHREAD is not defined, but RLIMIT_NTHR is,
+ use RLIMIT_NTHR (NetBSD)
+
+ 11/5
+ ----
+locale.c
+ - set_default_locale_vars,set_locale_var: if TEXTDOMAINDIR has been
+ set, and default_dir has a non-null value, call bindtextdomain(3)
+ when TEXTDOMAIN is assigned a value. Fixes problem reported by
+ Michael Arlt <qwertologe@googlemail.com>
+
+ 11/6
+ ----
+builtins/cd.def
+ - cdxattr: only create synthetic pathname in `buf' if NDIRP argument
+ is non-null
+ - change_to_directory: if we have specified -@ and cdxattr returns
+ failure, fail immediately. Fixes bug reported by Joshuah Hurst
+ <joshhurst@gmail.com>
+
+ 11/12
+ -----
+redir.c
+ - print_redirection: change r_err_and_out (&>) and its append form,
+ r_append_err_and_out (&>>) cases to separate redirection operator
+ from filename by a space, in case we have a process substitution.
+ Fixes bug reported by admn ombres <admn.ombres@gmail.com>
+
+ 11/15
+ -----
+execute_cmd.c
+ - execute_simple_command: don't close process substitution fds until
+ we are finished executing any current shell function. Partial fix
+ for bug reported by John Dawson <john.dawson@gmail.com>
+
+support/shobj-conf
+ - add support for Darwin 13 (Mac OS X 10.9, Mavericks). Based on a
+ report by Ludwig Schwardt <ludwig.schwardt@gmail.com>
+
+ 11/20
+ -----
+[bash-4.3-rc1 frozen]
+
+ 11/24
+ -----
+builtins/printf.def
+ - bind_printf_variable: make sure that the variable assigned to is
+ no longer marked as invisible. Fixes bug reported by NBaH
+ <nbah@sfr.fr>
+
+ 11/28
+ -----
+jobs.c
+ - delete_old_job: fix off-by-one error in job index in call to
+ internal_warning. Bug report from Peter Cordes <peter@cordes.ca>
+
+ 11/30
+ -----
+doc/bashref.texi
+ - add string to description of special parameters with name of
+ special parameter prefixed by a $, so you can search for $#,
+ for instance
+
+ 12/2
+ ----
+lib/readline/{histexpand.c
+ - get_history_event: account for current_history() possibly returning
+ NULL. Report and fix from Pankaj Sharma <pankaj.s01@samsung.com>
+
+
+ 12/11
+ -----
+
+lib/readline/parse-colors.c
+ - get_funky_string: don't call abort if we see something we can't
+ parse; just return an error
+ - _rl_parse_colors: if we encounter an error while parsing $LS_COLORS
+ we need to leave _rl_color_ext_list as NULL after freeing its
+ elements, then turn off _rl_colored_stats. Report and fix from Martin
+ Wesdorp <mwesdorp@casema.nl>
+
+ 12/13
+ -----
+
+lib/readline/parse-colors.c
+ - _rl_parse_colors: if we encounter an unrecognized prefix, throw an
+ error but try to recover and go on to the next specification
+
+variables.c
+ - make_local_variable: for new variables this function creates, set
+ the att_invisible attribute. All callers from declare_internal.
+ Indirectly, this is a fix for bug with `declare -n var; var=foo;'
+ reported by Pierre Gaston <pierre.gaston@gmail.com>
+ - bind_variable: if assigning to nameref variable that doesn't have
+ a value yet (e.g., with `declare -n var; var=foo'), don't try to
+ use the unset name. Fixes a segfault reported by Pierre Gaston
+ <pierre.gaston@gmail.com>
+
+execute_cmd.c
+ - execute_command_internal: make sure last_command_exit_value is set
+ to 0 after any command executed in the background. Fixes bug
+ reported by Martin Kealey <martin@kurahaupo.gen.nz>
+
+ 12/17
+ -----
+support/config.{guess,sub}
+ - updated to latest versions from git
+
+ 12/19
+ -----
+parse.y
+ - struct STRING_SAVER: now has a new `flags' element, to identify the
+ caller: alias expansion, double-paren parsing, or parse_and_execute
+ - push_string: now sets flags to PSH_ALIAS if `ap' argument is non-NULL
+ - push_string: now doesn't attempt to call strlen on a NULL string to
+ set shell_input_line_size
+ - parser_expanding_alias, parser_save_alias, parser_restore_alias: new
+ functions to provide an external interface to push_string and
+ pop_string; parser_save_alias sets flags element to PSH_SOURCE (could
+ be renamed PSH_EXTERN someday)
+ - shell_getc: when yy_getc returns '\0', instead of just testing
+ whether the pushed_string_list is not-empty before popping it, don't
+ pop if if the saved string has flags PSH_SOURCE, indicating that
+ parse_and_execute set it before setting bash_input to the string.
+ We should continue reading to the end of that string before popping
+ back to a potential alias. Partial solution for the problem of aliases
+ with embedded newlines containing `.' commands being executed out of
+ order reported by Andrew Martin <andrew.martin@gmail.com>
+ - shell_getc: when yy_getc returns '\0' and there is a saved string of
+ type PSH_SOURCE, restart the read without popping the string stack
+ if we have not read to the end of bash_input.location.string. Rest
+ of fix for out-of-order execution problem
+
+externs.h
+ - parser_expanding_alias, parser_save_alias, parser_restore_alias: new
+ extern function declarations
+
+builtins/evalstring.c
+ - pe_prologue: if the parser is expanding an alias, make sure to add
+ an unwind-protect to restore the alias; undoes the work that will be
+ performed by parse_and_execute/parse_string
+ - parse_and_execute,parse_string: after calling push_stream to save
+ bash_input, check whether or not the parser is currently expanding
+ an alias (parser_expanding_alias() != 0). If it is, we want to save
+ that string in the pushed_string_list, which we do with
+ parser_save_alias.
+
+ 12/23
+ -----
+execute_cmd.c
+ - execute_for_command: make sure to set line_number before expanding
+ the word list, so expansion errors have the right line number.
+ From a report from Ben Okopnik <ben@okopnik.com>
+
+expr.c
+ - exp2: save token pointer before calling readtok(), arrange to use
+ saved token pointer when printing error token on a division by 0
+ error
+
+ 12/27
+ -----
+lib/readline/display.c
+ - rl_redisplay: when calculating effects of invisible characters in a
+ prompt that is split across physical screen lines to set the indices
+ of linebreaks, don't bother testing local_prompt_prefix (line 751).
+ That prefix doesn't matter when calculating prompt visible and
+ invisible characters. Fixes problem reported by Jinesh Choksi
+ <jinesh@onelittlehope.com>
+
+Makefile.in
+ - install: make sure to use $(DESTDIR) when installing OTHER_DOCS.
+ Report and fix from Matthias Klose <doko@debian.org>
+
+doc/texinfo.tex
+ - updated to version of 2013-09-11
+
+ 12/28
+ -----
+lib/readline/undo.c
+ - rl_do_undo: if we are undoing from a history entry (rl_undo_list ==
+ current_history()->data), make sure the change to rl_line_buffer is
+ reflected in the history entry. We use the guts of
+ rl_maybe_replace_line to do the work. Fixes problem reported by
+ gregrwm <backuppc-users@whitleymott.net>
+
+ 12/30
+ -----
+sig.c
+ - sigint_sighandler: if we get a SIGINT (and this signal handler is
+ installed) while the wait builtin is running, note that we received
+ it in the same way as jobs.c:wait_sigint_handler and return. The
+ various wait_for functions will look for that with CHECK_WAIT_INTR.
+ This fixes the wait builtin not being interruptible in an interactive
+ job control shell
+
+ 12/31
+ -----
+trap.c
+ - set_signal_hard_ignored: rename set_signal_ignored to this, since it
+ both sets original_signals[sig] and sets the HARD_IGNORE flag
+ - set_signal_ignored: new function, now just sets original_signals[sig]
+
+trap.h
+ - set_signal_hard_ignored: new external declaration
+
+sig.c
+ - initialize_terminating_signals: call set_signal_hard_ignored instead
+ of set_signal_ignored for signals with disposition SIG_IGN when the
+ shell starts
+
+execute_cmd.c
+ - setup_async_signals: make sure we get the original dispositions for
+ SIGINT and SIGQUIT before starting the subshell, and don't call
+ set_signal_ignored because that sets original_signals[sig]. If we
+ don't, subsequent attempts to reset handling using trap will fail
+ because it thinks the original dispositions were SIG_IGN. Posix
+ interpretation 751 (http://austingroupbugs.net/view.php?id=751)
+
+ 1/2/2014
+ --------
+lib/sh/stringvec.c
+ - strvec_mcreate, strvec_mresize: versions of create and resize that
+ use malloc and realloc, respectively, instead of xmalloc/xrealloc
+
+braces.c
+ - expand_amble,mkseq: use strvec_mcreate/strvec_mresize so we can
+ catch and handle memory allocation failures instead of aborting
+ with the xmalloc/xrealloc interface
+
+lib/sh/strdup.c
+ - strdup replacement function for ancient systems that don't have it
+
+lib/sh/itos.c
+ - mitos: new function, itos that uses strdup instead of savestring
+
+externs.h
+ - strvec_mcreate/strvec_mresize: new extern declarations
+ - mitos: new extern declaration
+
+configure.ac
+ - bash version moved to 4.3-rc2
+
+ 1/6
+ ---
+doc/bash.1,lib/readline/doc/{rluser.texi,readline.3}
+ - separate the description of what happens when readline reads the
+ tty EOF character from the description of delete-char, leaving a
+ note in the delete-char description about common binding for ^D.
+ From suggestion by Parke <parke.nexus@gmail.com>
+
+lib/readline/doc/{version.texi,history.3,*.texi}
+ - updated email addresses and copyright dates
+
+ 1/7
+ ---
+variables.c
+ - delete_var: new function, just removes a variable from a hash table
+ and frees it, without doing anything else
+ - make_variable_value: if we are trying to assign to a nameref variable,
+ return NULL if the value is null or the empty string or not a valid
+ identifier
+
+variables.h
+ - delete_var: new extern declaration
+
+subst.h
+ - ASS_NAMEREF: new define for assignments, means assigning to a nameref
+ variable
+
+builtins/declare.def
+ - declare_internal: if we are creating and assigning to a nameref
+ variable, make sure the value is a valid variable name (checks done
+ by make_variable_value via bind_variable_value) and display an
+ error message, deleting the variable we just created, if it is not.
+ Fixes bug reported by Peggy Russell <prusselltechgroup@gmail.com>
+
+ 1/9
+ ---
+builtins/declare.def
+ - declare_internal: turning on nameref attribute for an existing
+ variable turns off -i/-l/-u/-c attributes (essentially the ones
+ that cause evaluation at assignment time) for ksh93 compat
+
+builtins/setattr.def
+ - show_name_attributes: if asked to display attributes and values for
+ a nameref variable, don't follow the nameref chain to the end. More
+ ksh93 compat
+
+ 1/10
+ ----
+trap.c
+ - _run_trap_internal: use {save,restore}_parser_state instead of
+ {save,restore}_token_state, like in run_pending_traps(); don't
+ need to save and restore last_command_exit_value as a result
+ - _run_trap_internal: call {save,restore}_pipeline like in
+ run_pending_traps()
+ - run_pending_traps: since we no longer run traps in a signal handler
+ context, do not block and unblock the trapped signal while the
+ trap is executing
+ - run_pending_traps: allow recursive invocations (basically, running
+ traps from a trap handler) with only a warning if the shell is
+ compiled in debug mode. If a caller doesn't want this to happen,
+ it should test running_trap > 0. signal_in_progress (sig) only works
+ for the signals the shell handles specially
+
+bashline.c
+ - bash_event_hook: make sure we clean up readline if interrupt_state
+ is set, not only when SIGINT is not trapped. check_signals_and_traps
+ will call check_signals, which calls QUIT, which will longjmp back
+ to top_level, running the interrupt trap along the way. Fixes the
+ problem of signal handlers being reset out from under readline, and
+ not being set properly the next time readline is called, because
+ signals_set_flag is still set to 1. XXX - might need to do this
+ for other signals too?
+
+ 1/11
+ ----
+subst.h
+ - SD_GLOB: new define for skip_to_delim; means we are scanning a
+ glob pattern.
+
+subst.c
+ - skip_to_delim: if flags include SD_GLOB, assume we are scanning a
+ glob pattern. Currently only used to skip bracket expressions
+ which may contain one of the delimiters
+
+ 1/12
+ ----
+subst.c
+ - parameter_brace_expand: when expanding $@ as part of substring
+ expansion, pattern substitution, or case modification, don't turn
+ on the QUOTED_NULL flag. The code that constructs the word to be
+ returned from expand_word_internal expects a different code path
+ when $@ is being expanded. Fixes bug reported by Theodoros
+ V. Kalamatianos <thkala@gmail.com>
+
+ 1/19
+ ----
+subst.c
+ - list_dequote_escapes: new function; analogue of list_quote_escapes
+
+pathexp.c
+ - quote_string_for_globbing: fix case where unescaped ^A is last char
+ in string; need to pass it through unaltered instead of turning it
+ into a bare backslash
+ - quote_string_for_globbing: when quoting for regexp matching in [[,
+ don't treat backslash as a quote character; quote the backslash as
+ any other character. Part of investigation into reports from
+ Eduardo A. Bustamante López <dualbus@gmail.com>
+
+ 1/25
+ ----
+builtins/gen-helpfiles.c
+ - write_helpfiles: add prototype
+ - make sure to #undef xmalloc/xfree/xrealloc/free if USING_BASH_MALLOC
+ is defined. the code does not use them, and we don't link against
+ xmalloc.o. Report from Linda Walsh <bash@tlinx.org>
+
+Makefile.in
+ - variables.o: add dependency on builtins/builtext.h; helps with
+ parallel builds. Report from Linda Walsh <bash@tlinx.org>
+
+support/shobj-conf
+ - darwin: combine the stanzas into one that will not require them to
+ be updated on each Mac OS X release. Report and fix from Max Horn
+ <max@quendi.de>
+
+ 1/27
+ ----
+support/shobj-conf
+ - darwin: changed the install_name embedded into the shared library
+ to contain only the major version number, not the minor one. The
+ idea is that the minor versions should all be API/ABI compatible,
+ and it is better to link automatically with the latest one. Idea
+ from Max Horn <max@quendi.de>
+
+ 1/29
+ ----
+[bash-4.3-rc2 released]
+
+ 1/30
+ ----
+lib/readline/readline.h
+ - rl_clear_history, rl_free_keymap: add extern declarations. Report
+ from Hiroo Hayashi <hiroo.hayashi@computer.org>
+
+general.c
+ - include trap.h for any_signals_trapped() prototype
+
+lib/sh/unicode.c
+ - include <stdio.h> for sprintf prototype
+
+ 1/31
+ ----
+execute_cmd.c
+ - execute_simple_command: only posix-mode shells should exit on an
+ assignment failure in the temporary environment preceding a special
+ builtin. This is what the documentation and code comments have
+ always said
+ - execute_simple_command: make sure redirection errors, word expansion
+ errors, and assignment errors to Posix special builtins cause a
+ non-interactive posix mode shell to exit. Previously the shell
+ would not exit if the failed special builtin was on the LHS of ||
+ or &&
+
+pathexp.c
+ - quote_string_for_globbing: when quoting a regular expression
+ (QGLOB_REGEXP), allow an unquoted backslash to pass through
+ unaltered. Don't use it as a quote character or quote it. More
+ investigation from 1/24 and report by Mike Frysinger
+ <vapier@gentoo.org>
+ - quote_string_for_globbing: when quoting a regular expression
+ (QGLOB_REGEXP), turn CTLESC CTLESC into CTLESC without adding a
+ backslash to quote it. We should not have to quote it because it is
+ not a character special to EREs. More investigation from 1/24
+
+lib/glob/glob.c
+ - glob_testdir: now takes a second flags argument (currently unused);
+ changed prototype and callers
+
+ 2/1
+ ---
+lib/glob/glob.c
+ - glob_testdir: if flags argument includes GX_ALLDIRS (globstar), use
+ lstat so we skip symlinks when traversing the directory tree.
+ Originally reported by Chris Down <chris@chrisdown.name>
+
+ 2/2
+ ---
+lib/readline/undo.c
+ - rl_do_undo: make sure CUR is non-zero before dereferencing it to
+ check cur->data against rl_undo_list. Report and fix from
+ Andreas Schwab <schwab@linux-m68k.org>
+
+doc/{bash.1,bashref.texi}
+ - added slight clarifying language to the description of $*,
+ describing what happens when the expansion is not within double
+ quotes
+
+ 2/4
+ ---
+test.c
+ - unary_test: add code to -v case so that it interprets `bare' array
+ references (foo[1]) and returns true if that index has a value
+
+ 2/5
+ ---
+trap.c
+ - restore_default_signal: fix SIGCHLD special case for SIG_TRAPPED flag
+ off but SIG_INPROGRESS mode set and handler IMPOSSIBLE_TRAP_HANDLER;
+ continue with resetting handler in this case. maybe_set_sigchld_trap
+ will check these things before resetting sigchld trap from
+ run_sigchld_trap. Fixes (apparently long-standing?) problem reported
+ by Alexandru Damian <alexandru.damian@intel.com>
+
+ 2/6
+ ---
+lib/sh/strtrans.c
+ - ansic_quote: fixed a bug when copying a printable character that
+ consumes more than one byte; byte counter was not being incremented.
+ Bug report from jidanni@jidanni.org
+
+ 2/7
+ ---
+input.c
+ - getc_with_restart: if read(2) returns -1/EINTR and interrupt_state or
+ terminating_signal is set (which means QUIT; will longjmp out of this
+ function), make sure the local buffer variables are zeroed out to
+ avoid reading past the end of the buffer on the next call. Bug report
+ from Dan Jacobson <jidanni@jidanni.org>
+
+ 2/9
+ ---
+bashline.c
+ - command_word_completion_function: if a directory in $PATH contains
+ quote characters, we need to quote them before passing the candidate
+ path to rl_filename_completion_function, which performs dequoting on
+ the pathname it's passed. Fixes bug reported by Ilyushkin Nikita
+ <ilyushkeane@gmail.com>
+
+ 2/11
+ ----
+parse.y
+ - xparse_dolparen: save and restore shell_eof_token around call to
+ parse_string, intead of just leaving it set to ')'
+ - shell_getc: when -v is set, only print the command line when
+ shell_eof_token is 0, so we don't print it multiple times when
+ recursively entering the parser to parse $(...) commands. Fixes
+ bug reported by Greg Wooledge <wooledg@eeg.ccf.org>
+
+[changed release status to 4.3-release]
+
+ 2/13
+ ----
+lib/sh/strtrans.c
+ - ansic_quote: handle case where mbrtowc reports that the multibyte
+ sequence is incomplete or invalid. Fixes bug reported by
+ Eduardo A. Bustamante López <dualbus@gmail.com>
+
+ 2/14
+ ----
+variables.c
+ - find_variable_nameref_context: fix a problem that caused the loop
+ to go one context too close to the global context. In some cases,
+ simple variable assignment would set a variable in the global
+ context instead of a local context. Bug report from
+ Geir Hauge <geir.hauge@gmail.com>
+
+ 2/26
+ ----
+[bash-4.3 released]
+
+ 2/27
+ ----
+aclocal.m4
+ - broken wcwidth check: fix typo reported by David Michael
+ <fedora.dm0@gmail.com>
+
+ 2/28
+ ----
+support/bashbug.sh
+ - add ${BUGADDR} to error message printed if sending mail fails
+
+trap.c
+ - _run_trap_internal: don't call {save,restore}_pipeline if running
+ DEBUG trap; run_debug_trap calls them itself. Fixes bug reported
+ by Moe Tunes <moetunes42@gmail.com>
+
+test.c
+ - unary_test: fix 'R' case by using find_variable_noref instead of
+ find_variable
+ - test_unop: add back missing 'R' case. Fixes bug reported by
+ NBaH <nbah@sfr.fr>
+
+ 3/2
+ ---
+jobs.c
+ - end_job_control: if job control is active, we changed the terminal's
+ process group, so make sure we restore it. Fixes bug reported by
+ Eduardo A. Bustamante López <dualbus@gmail.com>
+
+ 3/7
+ ---
+pcomplete.c
+ - pcomp_curtxt: new variable, holds the original text to be completed
+ as passed to the programmable completion code
+ - pcomp_filename_completion_function: if we are running compgen
+ (presumably in a shell function completion) and performing readline
+ completion, check the word being completed. If it's not empty, but
+ the original word passed to the programmable completion code is an
+ empty string (""), call a dequoting function if one is available.
+ This compensates for an assumption in bash-completion. Reported by
+ Albert Shih <Albert.Shih@obspm.fr>
+
+lib/readline/readline.c
+ - _rl_dispatch_subseq: when deciding whether or not to set vi mode's
+ idea of the last command, use whether or not the dispatching keymap
+ is vi_movement_keymap instead of the key sequence length. The `c',
+ `d', and `y' commands all take motion commands as `arguments' and
+ will produce key sequences longer than 1 character. The arrow keys
+ will end up dispatching out of a different keymap, so the test will
+ prevent arrow keys from setting the last command (the problem in
+ bash-4.2). Bug report from Daan van Rossum <daan@flash.uchicago.edu>
+
+lib/readline/vi_mode.c
+ - _rl_vi_motion_command: convenience function to test whether a key is
+ a vi-mode motion command
+
+lib/readline/rlprivate.h
+ - _rl_vi_motion_command: extern declaration
+
+parse.y
+ - parse_matched_pair: we should not skip processing single quotes in
+ posix mode if dolbrace_state == DOLBRACE_QUOTE2 (pattern
+ substitution). Fixes bug reported by David Sines
+ <dave.gma@googlemail.com>
+
+ 3/10
+ ----
+lib/readline/readline.c
+ - _rl_dispatch_callback: treat a return value of -1 as the end of
+ a command dispatch sequence if the current context doesn't
+ indicate that we're reading a multi-key sequence
+ ((cxt->flags & KSEQ_SUBSEQ) == 0). Turn off the multikey flag
+ and free the context chain in this case. Fixes one bug reported
+ by Felix Yan <felixonmars@gmail.com> to bug-readline list
+ - _rl_dispatch_callback: treat a return value of > 0 the same as 0
+ and return from the function, since only values < 0 cause us to
+ simulate recursion. Rest of fix for bug tracked down by
+ Anatol Pomozov <anatol.pomozov@gmail.com>
+
+ 3/11
+ ----
+
+execute_cmd.c
+ - execute_in_subshell: if a longjmp occurs, set result to
+ EXECUTION_FAILURE only if last_command_exit_value == EXECUTION_SUCCESS;
+ use value of last_command_exit_value otherwise. Fixes cosmetic
+ issue reported by Dennis Lambe Jr. <malsyned@malsyned.net>
+
+doc/bash.1
+ - shell-kill-word and shell-backward-kill-word should be documented
+ as unbound by default. Report from Oliver Hartley
+ <ohartley@talktalk.net>
+
+trap.c
+ - run_pending_traps: save value of $? before running trap commands in
+ trap_saved_exit_value, like run_exit_trap
+ - _run_trap_internal: save value of $? before running trap commands in
+ trap_saved_exit_value, like run_exit_trap
+
+builtins/common.c
+ - get_exitstat: when running `return' in a trap action, and it is not
+ supplied an argument, use the saved exit status in
+ trap_saved_exit_value. Fixes Posix problem reported by
+ Eduardo A. Bustamante López <dualbus@gmail.com>
+
+ 3/13
+ ----
+lib/sh/shquote.c
+ - sh_contains_quotes: new function, returns true if a given string
+ contains any of the shell quote characters (single quote, double
+ quote, or backslash)
+
+externs.h
+ - sh_contains_quotes: new extern declaration
+
+pcomplete.c
+ - pcomp_filename_completion_function: more changes for the benefit of
+ bash-completion: if the argument is not the same as the original
+ argument passed to the programmable completion code (pcomp_curtxt),
+ and we are being run by compgen as part of a completion, dequote the
+ argument as bash-completion expects. Fix for the complete-word-
+ with-quoted-special-chars problem with bash-completion
+
+ 3/17
+ ----
+execute_cmd.c
+ - execute_intern_function: when in posix mode, make defining a function
+ with the same name as a special builtin a fatal error only when the
+ shell is not interactive. Interactive shells display an error
+ message and go on. From a discussion with Doug McIlroy
+ <doug@cs.dartmouth.edu>
+
+ 3/18
+ ----
+arrayfunc.c
+ - assign_compound_array_list: when using expand_assignment_string_to_string
+ to expand the value in a ( [x]=y ) compound assignment, make sure
+ that we convert 0x0 to "" when expanding [x]= so it doesn't appear as
+ if the index is unset. Fixes bug reported by Geir Hauge
+ <geir.hauge@gmail.com>
+
+builtins/common.c
+ - get_exitstat: update fix of 3/11 to allow the DEBUG trap to use the
+ current value of $? instead of the value it had before the trap
+ action was run. This is one reason the DEBUG trap exists, and
+ extended debug mode uses it. Might want to do this only in Posix
+ mode
+
+doc/{bash.1,bashref.texi}
+ - return: add language cribbed from Posix saying what happens when
+ return is run without an argument from a trap, including the DEBUG
+ trap exception
+
+ 3/19
+ ----
+lib/glob/gmisc.c
+ - extglob_pattern_p: make sure ?(patlist) is flagged as an extglob
+ pattern
+
+lib/glob/glob.c
+ - extglob_skipname: rewrite to handle patterns that begin but do not
+ end with an extglob pattern; change test for easy case and loop
+ through patterns accordingly. Fixes problem with matching filenames
+ with a leading dot reported by Stephane Chazelas
+ <stephane.chazelas@gmail.com>
+ - wextglob_skipname: make analogous changes
+
+ 3/20
+ ----
+Makefile.in
+ - pass -DDEBUG down to builds in readline and history directories
+
+lib/readline/util.c
+ - _rl_trace and related functions are now only compiled in if DEBUG
+ is defined
+
+lib/readline/Makefile.in
+ - substitute @DEBUG@ and pass -DDEBUG, if necessary, to compilation
+ in LOCAL_CFLAGS
+
+ 3/21
+ ----
+parse.y
+ - shell_getc: when checking whether or not to reallocate
+ shell_input_line to add trailing newline, don't try to subtract from
+ shell_input_line_size. size_t is unsigned, so if its value is less
+ than 3 (like, say, 2), size-3 is a very large number and the string
+ will not be reallocated. Use len+3 > size instead of len > size-3.
+ Fixes bug reported in
+ https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1295467
+
+ 3/27
+ ----
+lib/readline/display.c
+ - _rl_clean_up_for_exit: don't bother to call _rl_move_vert to whatever
+ readline thinks the last displayed line is if it's 0. Two reasons: a
+ minor optimization, and it protects against unwanted moving if this
+ function is called twice, as it is when ^C is pressed. Fixes bug
+ reported by Egmont Koblinger <egmont@gmail.com>
+
+ 3/28
+ ----
+bashline.c
+ - invalid_completion: new function, used to identify attempts to
+ complete words that are syntax errors
+ - attempt_shell_completion: if invalid_completion returns true for a
+ word in a command position, punt on all completions. Fixes cosmetic
+ issue reported by Uwe Storbeck <uwe@ibr.ch>
+ - attempt_shell_completion: add clause so that in_command_position
+ remains set to 1 for an empty word following a command separator like
+ (, &, or |
+
+lib/readline/kill.c
+ - rl_yank, rl_yank_nth_arg_internal: don't return -1 from bindable
+ functions, return 1 instead
+
+lib/readline/text.c
+ - rl_rubout, _rl_rubout_char, rl_delete, rl_change_case,
+ rl_transpose_chars, rl_transpose_words, _rl_set_mark_at_pos,
+ rl_exchange_point_and_mark, _rl_insert_next, _rl_char_search,
+ _rl_char_search_internal:
+ don't return -1 from bindable functions, return 1 instead
+
+lib/readline/vi_mode.c
+ - rl_vi_end_word, rl_vi_rubout, rl_vi_delete, rl_vi_char_search,
+ rl_vi_match, _rl_vi_set_mark, _rl_vi_goto_mark:
+ don't return -1 from bindable functions, return 1 instead
+
+lib/readline/macro.c
+ - rl_start_kbd_macro, rl_end_kbd_macro:
+ don't return -1 from bindable functions, return 1 instead
+
+builtins/setattr.def
+ - set_var_attribute: honor setting of no_invisible_vars when setting
+ att_invisible on a variable
+ - include "../flags.h" for no_invisible_vars
+
+builtins/declare.def
+ - declare_internal: honor setting of no_invisible_vars when setting
+ att_invisible on a variable
+ - include "../flags.h" for no_invisible_vars
+
+Makefile.in,builtins/Makefile.in
+ - make sure declare.o and setattr.o depend on flags.h
+
+execute_cmd.c
+ - decpoint: new function, returns locale's decimal point or `.' default
+ - mkfmt: use decpoint() to get decimal point instead of unconditionally
+ using `.'. Fixes bug reported by Andrey Tataranovich
+ <tataranovich@gmail.com> in debian bug 741669
+
+ 4/10
+ ----
+lib/readline/rltypedefs.h
+ - add back old Function/VFunction/etc typedefs, since other packages
+ (python, samba) use them. Mark as deprecated using gcc and clang
+ attributes. Report and fix from Max Horn <max@quendi.de>
+
+ 4/14
+ ----
+jobs.c
+ - run_sigchld_trap: unwind-protect value of this_shell_builtin, since
+ it matters in some cases whether or not we are running `wait' or
+ `eval'. Fixes bug reported by Eduardo A. Bustamante López
+ <dualbus@gmail.com>
+
+ 4/18
+ ----
+shell.h
+ - sh_parser_state_t: add `need_here_doc' flags member, since
+ xparse_dolparen (via parse_command) sets it to 0
+
+parse.y
+ - gather_here_documents: make sure need_here_doc is > 0, since we
+ don't want to just decrement it forever if it ends up < 0. Partial
+ fix for bug reported by Jared Yanovich <slovichon@gmail.com>
+ - {save,restore}_parser_state: save and restore need_here_doc flag.
+ Rest of fix for bug reported by Jared Yanovich <slovichon@gmail.com>
+
+ 4/19
+ ----
+subst.c
+ - cond_expand_word: since we are not supposed to be performing word
+ splitting here, set expand_no_split_dollar_star to 1 in addition to
+ setting W_NOSPLIT2
+ - expand_word_internal: if we have a case where we have an unquoted
+ $@ but we are in a case where we don't want to split (W_NOSPLIT2),
+ make sure we return a list consisting of a single word with the
+ arguments separated by spaces and don't do word splitting. Fixes
+ bug reported by Greg Wooledge <wooledg@eeg.ccf.org> from an IRC
+ discussion
+
+builtins/hash.def
+ - print_portable_hash_info: single-quote pathnames and hashed filenames
+ that contain shell metacharacters. Fixes bug reported by
+ <g1pi@libero.it> in debian bash bug #739853
+
+ 4/20
+ ----
+lib/readline/display.c
+ - When using horizontal scrolling, the redisplay code erases too much
+ of the line containing successful results, so make sure we only
+ erase to the end of the line after making sure we move the cursor
+ to the end. Fixes bug reported by <Trond.Endrestol@ximalas.info>
+
+ 4/23
+ ----
+{bashhist,bashline}.c
+builtins{bind,help,type}.def
+lib/glob/glob.c, lib/intl/{loadmsgcat,localealias}.c,lib/sh/mktime.c
+ - fixes to memory leaks uncovered by coverity scan
+
+ 4/24
+ ----
+{bashhist,subst,redir,assoc,jobs,array,trap}.c
+lib/intl/l10flist.c
+builtins/complete.def
+ - fixes to memory leaks and other resource usage problems uncovered by
+ coverity scan
+
+redir.c
+ - do_redirection_internal: if dup2 fails (presumably because of a
+ resource limit), close the file descriptor we opened before returning
+ error
+
+ 4/25
+ ----
+config-top.h
+ - DEFAULT_BASHRC: new define with the name of the default shell
+ startup file
+
+bashline.c
+ - bash_directory_completion_matches: don't dequote the directory name.
+ If rl_completion_found_quote is non-zero, readline will dequote the
+ filename itself. Fixes bug reported by Clark Wang
+ <dearvoid@gmail.com>
+
+ 4/27
+ ----
+subst.c
+ - parameter_brace_expand_rhs: if parameter_brace_find_indir returns
+ NULL or "", or if it returns something that is not a valid identifier,
+ report an error and return &expand_wdesc_error so the error can
+ propagate up. Fixes bug reported by Andre Holzhey
+ <andre.holzhey@gmx.de>
+
+ 4/29
+ ----
+subst.c
+ - parameter_brace_substring: don't short-circuit right away if the
+ value is NULL but we are looking at the positional parameters. Part
+ of fix for bug reported by Pierre Gaston <pierre.gaston@gmail.com>
+ - pos_params: if there are no positional parameters, only short-circuit
+ if we are looking for $1 and above. Rest of fix for bug reported
+ by Pierre Gaston <pierre.gaston@gmail.com>
+
+subst.h
+ - SD_NOPROCSUB: new flag for skip_to_delim, means to not allow any
+ process subsitutions (should not have overloaded SD_NOSKIPCMD)
+
+subst.c
+ - skip_to_delim: honor SD_NOPROCSUB flag
+
+make_cmd.c
+ - make_arith_for_expr: set W_NOPROCSUB flag in the created word
+ - make_arith_for_command: set SD_NOPROCSUB in the flags argument to
+ skip_to_delim so we don't treat <( or >( as a process substitution
+ (we won't evaluate them in eval_arith_for_expr anyway). Fixes
+ bug reported by Pierre Gaston <pierre.gaston@gmail.com>
+
+ 5/1
+ ---
+lib/glob/gmisc.c
+ - glob_dirscan: new function, takes a pattern and a directory separator
+ argument and advances the pattern to the last occurrence of the
+ separator. Like strrchr, but understands extended glob patterns and
+ uses glob_patscan to skip over them
+
+lib/glob/glob.c
+ - extglob_skipname: if the extended globbing pattern is invalid, don't
+ skip the name
+ - glob_filename: if there is a slash in the pattern to be matched, and
+ extglob is enabled, use glob_dirscan to find the real last occurrence
+ of `/' to avoid being confused by slashes in extglob patterns. Fix
+ for bug reported by Pierre Gaston <pierre.gaston@gmail.com>
+
+ 5/6
+ ---
+variables.c
+ - make_local_variable: only set the att_invisible attribute if
+ no_invisible_vars isn't set
+ - find_variable_for_assignment: new function, intended to be called by
+ code that eventually wants to assign a value to the variable; will not
+ skip invisible variables; currently identical to find_variable
+ - find_variable_no_invisible: new function, finds the first visible
+ instance of variable with a given name in the variable context chain;
+ eventually will be used to replace find_variable; separate right now
+ for testing
+
+variables.h
+ - find_variable_for_assignment: extern declaration
+ - find_variable_no_invisible: extern declaration
+
+ 5/7
+ ---
+variables.c
+ - make_local_variable: don't clear `invisible' attribute if we are
+ returning an existing local variable at the right context. Let the
+ upper layers do that. Fixes bug reported by Dan Douglas
+ <ormaaj@gmail.com>
+
+ 5/8
+ ---
+lib/readline/input.c
+ - rl_getc: call RL_CHECK_SIGNALS if a read(2) is interrupted (-1/EINTR)
+ by SIGALRM or SIGVTALRM (placeholder for non-keyboard-generated
+ signals of interest)
+
+builtins/read.def
+ - edit_line: call bashline_set_event_hook and
+ bashline_reset_event_hook around call to readline(), so the right
+ signal handling happens
+ - read_builtin: make sure we add an unwind_protect call to
+ bashline_reset_event_hook. These changes fix bug reported in
+ https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1317476
+
+ 5/12
+ ----
+doc/{bash.1,bashref.texi}
+ - clarify language to make it clear that changing attributes of a
+ nameref variable (e.g., export), actually changes the attributes of
+ the referenced variable. Fixes omission noted by Jeff Haemer
+ <jeffrey.haemer@gmail.com>
+
+arrayfunc.c
+ - bind_array_var_internal: make sure ENTRY no longer has invisible
+ attribute before returning. Fixes bug reported by Geir Hauge
+ <geir.hauge@gmail.com>
+
+ 5/22
+ ----
+execute_cmd.c
+ - shell_execve: if execve fails and we return 127 or 126, make sure to
+ set last_command_exit_value if a call to file_error or report_error
+ causes the shell to exit. This ensures that the shell exits with
+ the right value.
+
+ 6/6
+ ---
+shell.c
+ - drop_priv_mode: print an error message on setuid() failure, optionally
+ exit if errno == EAGAIN, as it can be on Linux when RLIMIT_NPROC for
+ the target user is exceeded.
+
+config-top.h
+ - EXIT_ON_SETUID_FAILURE: new settable define, will cause the shell to
+ exit if setuid fails with errno == EAGAIN
+
+ 6/10
+ ----
+parse.y
+ - time_command_acceptable: fix so time is accepted everywhere the
+ grammar is looking for a `compound_list'. Fixes bug reported by
+ Dale Worley <worley@alum.mit.edu>
+
+ 6/12
+ ----
+subst.c
+ - clear_fifo_list: new function, clears FDs associated with open pipes
+ in current FIFO list without closing the file descriptors. Can
+ possibly be used when shell_execve fails and the shell jumps back
+ to top_level and we don't want the shell to close the open FIFOs
+ each time through the read-execute loop. Bug reported by Harald
+ Koenig <koenig@tat.physik.uni-tuebingen.de>
+
+
+ 6/16
+ ----
+builtins/shopt.def
+ - compat42: make sure the `compat42' option sets the correct variable
+ for compatibility level. Fixes bug reported by Ondrej Oprala
+ <ooprala@redhat.com>
--- /dev/null
+/* bashline.c -- Bash's interface to the readline library. */
+
+/* Copyright (C) 1987-2013 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Bash is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "config.h"
+
+#if defined (READLINE)
+
+#include "bashtypes.h"
+#include "posixstat.h"
+
+#if defined (HAVE_UNISTD_H)
+# include <unistd.h>
+#endif
+
+#if defined (HAVE_GRP_H)
+# include <grp.h>
+#endif
+
+#if defined (HAVE_NETDB_H)
+# include <netdb.h>
+#endif
+
+#include <signal.h>
+
+#include <stdio.h>
+#include "chartypes.h"
+#include "bashansi.h"
+#include "bashintl.h"
+
+#include "shell.h"
+#include "input.h"
+#include "builtins.h"
+#include "bashhist.h"
+#include "bashline.h"
+#include "execute_cmd.h"
+#include "findcmd.h"
+#include "pathexp.h"
+#include "shmbutil.h"
+#include "trap.h"
+
+#include "builtins/common.h"
+
+#include <readline/rlconf.h>
+#include <readline/readline.h>
+#include <readline/history.h>
+
+#include <glob/glob.h>
+
+#if defined (ALIAS)
+# include "alias.h"
+#endif
+
+#if defined (PROGRAMMABLE_COMPLETION)
+# include "pcomplete.h"
+#endif
+
+/* These should agree with the defines for emacs_mode and vi_mode in
+ rldefs.h, even though that's not a public readline header file. */
+#ifndef EMACS_EDITING_MODE
+# define NO_EDITING_MODE -1
+# define EMACS_EDITING_MODE 1
+# define VI_EDITING_MODE 0
+#endif
+
+#define RL_BOOLEAN_VARIABLE_VALUE(s) ((s)[0] == 'o' && (s)[1] == 'n' && (s)[2] == '\0')
+
+#if defined (BRACE_COMPLETION)
+extern int bash_brace_completion __P((int, int));
+#endif /* BRACE_COMPLETION */
+
+/* To avoid including curses.h/term.h/termcap.h and that whole mess. */
+#ifdef _MINIX
+extern int tputs __P((const char *string, int nlines, void (*outx)(int)));
+#else
+extern int tputs __P((const char *string, int nlines, int (*outx)(int)));
+#endif
+
+/* Forward declarations */
+
+/* Functions bound to keys in Readline for Bash users. */
+static int shell_expand_line __P((int, int));
+static int display_shell_version __P((int, int));
+static int operate_and_get_next __P((int, int));
+
+static int bash_ignore_filenames __P((char **));
+static int bash_ignore_everything __P((char **));
+
+#if defined (BANG_HISTORY)
+static char *history_expand_line_internal __P((char *));
+static int history_expand_line __P((int, int));
+static int tcsh_magic_space __P((int, int));
+#endif /* BANG_HISTORY */
+#ifdef ALIAS
+static int alias_expand_line __P((int, int));
+#endif
+#if defined (BANG_HISTORY) && defined (ALIAS)
+static int history_and_alias_expand_line __P((int, int));
+#endif
+
+static int bash_forward_shellword __P((int, int));
+static int bash_backward_shellword __P((int, int));
+static int bash_kill_shellword __P((int, int));
+static int bash_backward_kill_shellword __P((int, int));
+
+/* Helper functions for Readline. */
+static char *restore_tilde __P((char *, char *));
+static char *maybe_restore_tilde __P((char *, char *));
+
+static char *bash_filename_rewrite_hook __P((char *, int));
+
+static void bash_directory_expansion __P((char **));
+static int bash_filename_stat_hook __P((char **));
+static int bash_command_name_stat_hook __P((char **));
+static int bash_directory_completion_hook __P((char **));
+static int filename_completion_ignore __P((char **));
+static int bash_push_line __P((void));
+
+static int executable_completion __P((const char *, int));
+
+static rl_icppfunc_t *save_directory_hook __P((void));
+static void restore_directory_hook __P((rl_icppfunc_t));
+
+static void cleanup_expansion_error __P((void));
+static void maybe_make_readline_line __P((char *));
+static void set_up_new_line __P((char *));
+
+static int check_redir __P((int));
+static char **attempt_shell_completion __P((const char *, int, int));
+static char *variable_completion_function __P((const char *, int));
+static char *hostname_completion_function __P((const char *, int));
+static char *command_subst_completion_function __P((const char *, int));
+
+static void build_history_completion_array __P((void));
+static char *history_completion_generator __P((const char *, int));
+static int dynamic_complete_history __P((int, int));
+static int bash_dabbrev_expand __P((int, int));
+
+static void initialize_hostname_list __P((void));
+static void add_host_name __P((char *));
+static void snarf_hosts_from_file __P((char *));
+static char **hostnames_matching __P((char *));
+
+static void _ignore_completion_names __P((char **, sh_ignore_func_t *));
+static int name_is_acceptable __P((const char *));
+static int test_for_directory __P((const char *));
+static int return_zero __P((const char *));
+
+static char *bash_dequote_filename __P((char *, int));
+static char *quote_word_break_chars __P((char *));
+static void set_filename_bstab __P((const char *));
+static char *bash_quote_filename __P((char *, int, char *));
+
+#ifdef _MINIX
+static void putx __P((int));
+#else
+static int putx __P((int));
+#endif
+static int bash_execute_unix_command __P((int, int));
+static void init_unix_command_map __P((void));
+static int isolate_sequence __P((char *, int, int, int *));
+
+static int set_saved_history __P((void));
+
+#if defined (ALIAS)
+static int posix_edit_macros __P((int, int));
+#endif
+
+static int bash_event_hook __P((void));
+
+#if defined (PROGRAMMABLE_COMPLETION)
+static int find_cmd_start __P((int));
+static int find_cmd_end __P((int));
+static char *find_cmd_name __P((int, int *, int *));
+static char *prog_complete_return __P((const char *, int));
+
+static char **prog_complete_matches;
+#endif
+
+/* Variables used here but defined in other files. */
+#if defined (BANG_HISTORY)
+extern int hist_verify;
+#endif
+
+extern int current_command_line_count, saved_command_line_count;
+extern int last_command_exit_value;
+extern int array_needs_making;
+extern int posixly_correct, no_symbolic_links;
+extern int sigalrm_seen;
+extern char *current_prompt_string, *ps1_prompt;
+extern STRING_INT_ALIST word_token_alist[];
+extern sh_builtin_func_t *last_shell_builtin, *this_shell_builtin;
+
+/* SPECIFIC_COMPLETION_FUNCTIONS specifies that we have individual
+ completion functions which indicate what type of completion should be
+ done (at or before point) that can be bound to key sequences with
+ the readline library. */
+#define SPECIFIC_COMPLETION_FUNCTIONS
+
+#if defined (SPECIFIC_COMPLETION_FUNCTIONS)
+static int bash_specific_completion __P((int, rl_compentry_func_t *));
+
+static int bash_complete_filename_internal __P((int));
+static int bash_complete_username_internal __P((int));
+static int bash_complete_hostname_internal __P((int));
+static int bash_complete_variable_internal __P((int));
+static int bash_complete_command_internal __P((int));
+
+static int bash_complete_filename __P((int, int));
+static int bash_possible_filename_completions __P((int, int));
+static int bash_complete_username __P((int, int));
+static int bash_possible_username_completions __P((int, int));
+static int bash_complete_hostname __P((int, int));
+static int bash_possible_hostname_completions __P((int, int));
+static int bash_complete_variable __P((int, int));
+static int bash_possible_variable_completions __P((int, int));
+static int bash_complete_command __P((int, int));
+static int bash_possible_command_completions __P((int, int));
+
+static char *glob_complete_word __P((const char *, int));
+static int bash_glob_completion_internal __P((int));
+static int bash_glob_complete_word __P((int, int));
+static int bash_glob_expand_word __P((int, int));
+static int bash_glob_list_expansions __P((int, int));
+
+#endif /* SPECIFIC_COMPLETION_FUNCTIONS */
+
+static int edit_and_execute_command __P((int, int, int, char *));
+#if defined (VI_MODE)
+static int vi_edit_and_execute_command __P((int, int));
+static int bash_vi_complete __P((int, int));
+#endif
+static int emacs_edit_and_execute_command __P((int, int));
+
+/* Non-zero once initalize_readline () has been called. */
+int bash_readline_initialized = 0;
+
+/* If non-zero, we do hostname completion, breaking words at `@' and
+ trying to complete the stuff after the `@' from our own internal
+ host list. */
+int perform_hostname_completion = 1;
+
+/* If non-zero, we don't do command completion on an empty line. */
+int no_empty_command_completion;
+
+/* Set FORCE_FIGNORE if you want to honor FIGNORE even if it ignores the
+ only possible matches. Set to 0 if you want to match filenames if they
+ are the only possible matches, even if FIGNORE says to. */
+int force_fignore = 1;
+
+/* Perform spelling correction on directory names during word completion */
+int dircomplete_spelling = 0;
+
+/* Expand directory names during word/filename completion. */
+#if DIRCOMPLETE_EXPAND_DEFAULT
+int dircomplete_expand = 1;
+int dircomplete_expand_relpath = 1;
+#else
+int dircomplete_expand = 0;
+int dircomplete_expand_relpath = 0;
+#endif
+
+/* When non-zero, perform `normal' shell quoting on completed filenames
+ even when the completed name contains a directory name with a shell
+ variable referene, so dollar signs in a filename get quoted appropriately.
+ Set to zero to remove dollar sign (and braces or parens as needed) from
+ the set of characters that will be quoted. */
+int complete_fullquote = 1;
+
+static char *bash_completer_word_break_characters = " \t\n\"'@><=;|&(:";
+static char *bash_nohostname_word_break_characters = " \t\n\"'><=;|&(:";
+/* )) */
+
+static const char *default_filename_quote_characters = " \t\n\\\"'@<>=;|&()#$`?*[!:{~"; /*}*/
+static char *custom_filename_quote_characters = 0;
+static char filename_bstab[256];
+
+static rl_hook_func_t *old_rl_startup_hook = (rl_hook_func_t *)NULL;
+
+static int dot_in_path = 0;
+
+/* Set to non-zero when dabbrev-expand is running */
+static int dabbrev_expand_active = 0;
+
+/* What kind of quoting is performed by bash_quote_filename:
+ COMPLETE_DQUOTE = double-quoting the filename
+ COMPLETE_SQUOTE = single_quoting the filename
+ COMPLETE_BSQUOTE = backslash-quoting special chars in the filename
+*/
+#define COMPLETE_DQUOTE 1
+#define COMPLETE_SQUOTE 2
+#define COMPLETE_BSQUOTE 3
+static int completion_quoting_style = COMPLETE_BSQUOTE;
+
+/* Flag values for the final argument to bash_default_completion */
+#define DEFCOMP_CMDPOS 1
+
+/* Change the readline VI-mode keymaps into or out of Posix.2 compliance.
+ Called when the shell is put into or out of `posix' mode. */
+void
+posix_readline_initialize (on_or_off)
+ int on_or_off;
+{
+ if (on_or_off)
+ rl_variable_bind ("comment-begin", "#");
+#if defined (VI_MODE)
+ rl_bind_key_in_map (CTRL ('I'), on_or_off ? rl_insert : rl_complete, vi_insertion_keymap);
+#endif
+}
+
+void
+reset_completer_word_break_chars ()
+{
+ rl_completer_word_break_characters = perform_hostname_completion ? savestring (bash_completer_word_break_characters) : savestring (bash_nohostname_word_break_characters);
+}
+
+/* When this function returns, rl_completer_word_break_characters points to
+ dynamically allocated memory. */
+int
+enable_hostname_completion (on_or_off)
+ int on_or_off;
+{
+ int old_value;
+ char *at, *nv, *nval;
+
+ old_value = perform_hostname_completion;
+
+ if (on_or_off)
+ {
+ perform_hostname_completion = 1;
+ rl_special_prefixes = "$@";
+ }
+ else
+ {
+ perform_hostname_completion = 0;
+ rl_special_prefixes = "$";
+ }
+
+ /* Now we need to figure out how to appropriately modify and assign
+ rl_completer_word_break_characters depending on whether we want
+ hostname completion on or off. */
+
+ /* If this is the first time this has been called
+ (bash_readline_initialized == 0), use the sames values as before, but
+ allocate new memory for rl_completer_word_break_characters. */
+
+ if (bash_readline_initialized == 0 &&
+ (rl_completer_word_break_characters == 0 ||
+ rl_completer_word_break_characters == rl_basic_word_break_characters))
+ {
+ if (on_or_off)
+ rl_completer_word_break_characters = savestring (bash_completer_word_break_characters);
+ else
+ rl_completer_word_break_characters = savestring (bash_nohostname_word_break_characters);
+ }
+ else
+ {
+ /* See if we have anything to do. */
+ at = strchr (rl_completer_word_break_characters, '@');
+ if ((at == 0 && on_or_off == 0) || (at != 0 && on_or_off != 0))
+ return old_value;
+
+ /* We have something to do. Do it. */
+ nval = (char *)xmalloc (strlen (rl_completer_word_break_characters) + 1 + on_or_off);
+
+ if (on_or_off == 0)
+ {
+ /* Turn it off -- just remove `@' from word break chars. We want
+ to remove all occurrences of `@' from the char list, so we loop
+ rather than just copy the rest of the list over AT. */
+ for (nv = nval, at = rl_completer_word_break_characters; *at; )
+ if (*at != '@')
+ *nv++ = *at++;
+ else
+ at++;
+ *nv = '\0';
+ }
+ else
+ {
+ nval[0] = '@';
+ strcpy (nval + 1, rl_completer_word_break_characters);
+ }
+
+ free (rl_completer_word_break_characters);
+ rl_completer_word_break_characters = nval;
+ }
+
+ return (old_value);
+}
+
+/* Called once from parse.y if we are going to use readline. */
+void
+initialize_readline ()
+{
+ rl_command_func_t *func;
+ char kseq[2];
+
+ if (bash_readline_initialized)
+ return;
+
+ rl_terminal_name = get_string_value ("TERM");
+ rl_instream = stdin;
+ rl_outstream = stderr;
+
+ /* Allow conditional parsing of the ~/.inputrc file. */
+ rl_readline_name = "Bash";
+
+ /* Add bindable names before calling rl_initialize so they may be
+ referenced in the various inputrc files. */
+ rl_add_defun ("shell-expand-line", shell_expand_line, -1);
+#ifdef BANG_HISTORY
+ rl_add_defun ("history-expand-line", history_expand_line, -1);
+ rl_add_defun ("magic-space", tcsh_magic_space, -1);
+#endif
+
+ rl_add_defun ("shell-forward-word", bash_forward_shellword, -1);
+ rl_add_defun ("shell-backward-word", bash_backward_shellword, -1);
+ rl_add_defun ("shell-kill-word", bash_kill_shellword, -1);
+ rl_add_defun ("shell-backward-kill-word", bash_backward_kill_shellword, -1);
+
+#ifdef ALIAS
+ rl_add_defun ("alias-expand-line", alias_expand_line, -1);
+# ifdef BANG_HISTORY
+ rl_add_defun ("history-and-alias-expand-line", history_and_alias_expand_line, -1);
+# endif
+#endif
+
+ /* Backwards compatibility. */
+ rl_add_defun ("insert-last-argument", rl_yank_last_arg, -1);
+
+ rl_add_defun ("operate-and-get-next", operate_and_get_next, -1);
+ rl_add_defun ("display-shell-version", display_shell_version, -1);
+ rl_add_defun ("edit-and-execute-command", emacs_edit_and_execute_command, -1);
+
+#if defined (BRACE_COMPLETION)
+ rl_add_defun ("complete-into-braces", bash_brace_completion, -1);
+#endif
+
+#if defined (SPECIFIC_COMPLETION_FUNCTIONS)
+ rl_add_defun ("complete-filename", bash_complete_filename, -1);
+ rl_add_defun ("possible-filename-completions", bash_possible_filename_completions, -1);
+ rl_add_defun ("complete-username", bash_complete_username, -1);
+ rl_add_defun ("possible-username-completions", bash_possible_username_completions, -1);
+ rl_add_defun ("complete-hostname", bash_complete_hostname, -1);
+ rl_add_defun ("possible-hostname-completions", bash_possible_hostname_completions, -1);
+ rl_add_defun ("complete-variable", bash_complete_variable, -1);
+ rl_add_defun ("possible-variable-completions", bash_possible_variable_completions, -1);
+ rl_add_defun ("complete-command", bash_complete_command, -1);
+ rl_add_defun ("possible-command-completions", bash_possible_command_completions, -1);
+ rl_add_defun ("glob-complete-word", bash_glob_complete_word, -1);
+ rl_add_defun ("glob-expand-word", bash_glob_expand_word, -1);
+ rl_add_defun ("glob-list-expansions", bash_glob_list_expansions, -1);
+#endif
+
+ rl_add_defun ("dynamic-complete-history", dynamic_complete_history, -1);
+ rl_add_defun ("dabbrev-expand", bash_dabbrev_expand, -1);
+
+ /* Bind defaults before binding our custom shell keybindings. */
+ if (RL_ISSTATE(RL_STATE_INITIALIZED) == 0)
+ rl_initialize ();
+
+ /* Bind up our special shell functions. */
+ rl_bind_key_if_unbound_in_map (CTRL('E'), shell_expand_line, emacs_meta_keymap);
+
+#ifdef BANG_HISTORY
+ rl_bind_key_if_unbound_in_map ('^', history_expand_line, emacs_meta_keymap);
+#endif
+
+ rl_bind_key_if_unbound_in_map (CTRL ('O'), operate_and_get_next, emacs_standard_keymap);
+ rl_bind_key_if_unbound_in_map (CTRL ('V'), display_shell_version, emacs_ctlx_keymap);
+
+ /* In Bash, the user can switch editing modes with "set -o [vi emacs]",
+ so it is not necessary to allow C-M-j for context switching. Turn
+ off this occasionally confusing behaviour. */
+ kseq[0] = CTRL('J');
+ kseq[1] = '\0';
+ func = rl_function_of_keyseq (kseq, emacs_meta_keymap, (int *)NULL);
+ if (func == rl_vi_editing_mode)
+ rl_unbind_key_in_map (CTRL('J'), emacs_meta_keymap);
+ kseq[0] = CTRL('M');
+ func = rl_function_of_keyseq (kseq, emacs_meta_keymap, (int *)NULL);
+ if (func == rl_vi_editing_mode)
+ rl_unbind_key_in_map (CTRL('M'), emacs_meta_keymap);
+#if defined (VI_MODE)
+ rl_unbind_key_in_map (CTRL('E'), vi_movement_keymap);
+#endif
+
+#if defined (BRACE_COMPLETION)
+ rl_bind_key_if_unbound_in_map ('{', bash_brace_completion, emacs_meta_keymap); /*}*/
+#endif /* BRACE_COMPLETION */
+
+#if defined (SPECIFIC_COMPLETION_FUNCTIONS)
+ rl_bind_key_if_unbound_in_map ('/', bash_complete_filename, emacs_meta_keymap);
+ rl_bind_key_if_unbound_in_map ('/', bash_possible_filename_completions, emacs_ctlx_keymap);
+
+ /* Have to jump through hoops here because there is a default binding for
+ M-~ (rl_tilde_expand) */
+ kseq[0] = '~';
+ kseq[1] = '\0';
+ func = rl_function_of_keyseq (kseq, emacs_meta_keymap, (int *)NULL);
+ if (func == 0 || func == rl_tilde_expand)
+ rl_bind_keyseq_in_map (kseq, bash_complete_username, emacs_meta_keymap);
+
+ rl_bind_key_if_unbound_in_map ('~', bash_possible_username_completions, emacs_ctlx_keymap);
+
+ rl_bind_key_if_unbound_in_map ('@', bash_complete_hostname, emacs_meta_keymap);
+ rl_bind_key_if_unbound_in_map ('@', bash_possible_hostname_completions, emacs_ctlx_keymap);
+
+ rl_bind_key_if_unbound_in_map ('$', bash_complete_variable, emacs_meta_keymap);
+ rl_bind_key_if_unbound_in_map ('$', bash_possible_variable_completions, emacs_ctlx_keymap);
+
+ rl_bind_key_if_unbound_in_map ('!', bash_complete_command, emacs_meta_keymap);
+ rl_bind_key_if_unbound_in_map ('!', bash_possible_command_completions, emacs_ctlx_keymap);
+
+ rl_bind_key_if_unbound_in_map ('g', bash_glob_complete_word, emacs_meta_keymap);
+ rl_bind_key_if_unbound_in_map ('*', bash_glob_expand_word, emacs_ctlx_keymap);
+ rl_bind_key_if_unbound_in_map ('g', bash_glob_list_expansions, emacs_ctlx_keymap);
+
+#endif /* SPECIFIC_COMPLETION_FUNCTIONS */
+
+ kseq[0] = TAB;
+ kseq[1] = '\0';
+ func = rl_function_of_keyseq (kseq, emacs_meta_keymap, (int *)NULL);
+ if (func == 0 || func == rl_tab_insert)
+ rl_bind_key_in_map (TAB, dynamic_complete_history, emacs_meta_keymap);
+
+ /* Tell the completer that we want a crack first. */
+ rl_attempted_completion_function = attempt_shell_completion;
+
+ /* Tell the completer that we might want to follow symbolic links or
+ do other expansion on directory names. */
+ set_directory_hook ();
+
+ rl_filename_rewrite_hook = bash_filename_rewrite_hook;
+
+ rl_filename_stat_hook = bash_filename_stat_hook;
+
+ /* Tell the filename completer we want a chance to ignore some names. */
+ rl_ignore_some_completions_function = filename_completion_ignore;
+
+ /* Bind C-xC-e to invoke emacs and run result as commands. */
+ rl_bind_key_if_unbound_in_map (CTRL ('E'), emacs_edit_and_execute_command, emacs_ctlx_keymap);
+#if defined (VI_MODE)
+ rl_bind_key_if_unbound_in_map ('v', vi_edit_and_execute_command, vi_movement_keymap);
+# if defined (ALIAS)
+ rl_bind_key_if_unbound_in_map ('@', posix_edit_macros, vi_movement_keymap);
+# endif
+
+ rl_bind_key_in_map ('\\', bash_vi_complete, vi_movement_keymap);
+ rl_bind_key_in_map ('*', bash_vi_complete, vi_movement_keymap);
+ rl_bind_key_in_map ('=', bash_vi_complete, vi_movement_keymap);
+#endif
+
+ rl_completer_quote_characters = "'\"";
+
+ /* This sets rl_completer_word_break_characters and rl_special_prefixes
+ to the appropriate values, depending on whether or not hostname
+ completion is enabled. */
+ enable_hostname_completion (perform_hostname_completion);
+
+ /* characters that need to be quoted when appearing in filenames. */
+ rl_filename_quote_characters = default_filename_quote_characters;
+ set_filename_bstab (rl_filename_quote_characters);
+
+ rl_filename_quoting_function = bash_quote_filename;
+ rl_filename_dequoting_function = bash_dequote_filename;
+ rl_char_is_quoted_p = char_is_quoted;
+
+#if 0
+ /* This is superfluous and makes it impossible to use tab completion in
+ vi mode even when explicitly binding it in ~/.inputrc. sv_strict_posix()
+ should already have called posix_readline_initialize() when
+ posixly_correct was set. */
+ if (posixly_correct)
+ posix_readline_initialize (1);
+#endif
+
+ bash_readline_initialized = 1;
+}
+
+void
+bashline_reinitialize ()
+{
+ bash_readline_initialized = 0;
+}
+
+void
+bashline_set_event_hook ()
+{
+ rl_signal_event_hook = bash_event_hook;
+}
+
+void
+bashline_reset_event_hook ()
+{
+ rl_signal_event_hook = 0;
+}
+
+/* On Sun systems at least, rl_attempted_completion_function can end up
+ getting set to NULL, and rl_completion_entry_function set to do command
+ word completion if Bash is interrupted while trying to complete a command
+ word. This just resets all the completion functions to the right thing.
+ It's called from throw_to_top_level(). */
+void
+bashline_reset ()
+{
+ tilde_initialize ();
+ rl_attempted_completion_function = attempt_shell_completion;
+ rl_completion_entry_function = NULL;
+ rl_ignore_some_completions_function = filename_completion_ignore;
+ rl_filename_quote_characters = default_filename_quote_characters;
+ set_filename_bstab (rl_filename_quote_characters);
+
+ set_directory_hook ();
+ rl_filename_stat_hook = bash_filename_stat_hook;
+
+ bashline_reset_event_hook ();
+}
+
+/* Contains the line to push into readline. */
+static char *push_to_readline = (char *)NULL;
+
+/* Push the contents of push_to_readline into the
+ readline buffer. */
+static int
+bash_push_line ()
+{
+ if (push_to_readline)
+ {
+ rl_insert_text (push_to_readline);
+ free (push_to_readline);
+ push_to_readline = (char *)NULL;
+ rl_startup_hook = old_rl_startup_hook;
+ }
+ return 0;
+}
+
+/* Call this to set the initial text for the next line to read
+ from readline. */
+int
+bash_re_edit (line)
+ char *line;
+{
+ FREE (push_to_readline);
+
+ push_to_readline = savestring (line);
+ old_rl_startup_hook = rl_startup_hook;
+ rl_startup_hook = bash_push_line;
+
+ return (0);
+}
+
+static int
+display_shell_version (count, c)
+ int count, c;
+{
+ rl_crlf ();
+ show_shell_version (0);
+ putc ('\r', rl_outstream);
+ fflush (rl_outstream);
+ rl_on_new_line ();
+ rl_redisplay ();
+ return 0;
+}
+
+/* **************************************************************** */
+/* */
+/* Readline Stuff */
+/* */
+/* **************************************************************** */
+
+/* If the user requests hostname completion, then simply build a list
+ of hosts, and complete from that forever more, or at least until
+ HOSTFILE is unset. */
+
+/* THIS SHOULD BE A STRINGLIST. */
+/* The kept list of hostnames. */
+static char **hostname_list = (char **)NULL;
+
+/* The physical size of the above list. */
+static int hostname_list_size;
+
+/* The number of hostnames in the above list. */
+static int hostname_list_length;
+
+/* Whether or not HOSTNAME_LIST has been initialized. */
+int hostname_list_initialized = 0;
+
+/* Initialize the hostname completion table. */
+static void
+initialize_hostname_list ()
+{
+ char *temp;
+
+ temp = get_string_value ("HOSTFILE");
+ if (temp == 0)
+ temp = get_string_value ("hostname_completion_file");
+ if (temp == 0)
+ temp = DEFAULT_HOSTS_FILE;
+
+ snarf_hosts_from_file (temp);
+
+ if (hostname_list)
+ hostname_list_initialized++;
+}
+
+/* Add NAME to the list of hosts. */
+static void
+add_host_name (name)
+ char *name;
+{
+ if (hostname_list_length + 2 > hostname_list_size)
+ {
+ hostname_list_size = (hostname_list_size + 32) - (hostname_list_size % 32);
+ hostname_list = strvec_resize (hostname_list, hostname_list_size);
+ }
+
+ hostname_list[hostname_list_length++] = savestring (name);
+ hostname_list[hostname_list_length] = (char *)NULL;
+}
+
+#define cr_whitespace(c) ((c) == '\r' || (c) == '\n' || whitespace(c))
+
+static void
+snarf_hosts_from_file (filename)
+ char *filename;
+{
+ FILE *file;
+ char *temp, buffer[256], name[256];
+ register int i, start;
+
+ file = fopen (filename, "r");
+ if (file == 0)
+ return;
+
+ while (temp = fgets (buffer, 255, file))
+ {
+ /* Skip to first character. */
+ for (i = 0; buffer[i] && cr_whitespace (buffer[i]); i++)
+ ;
+
+ /* If comment or blank line, ignore. */
+ if (buffer[i] == '\0' || buffer[i] == '#')
+ continue;
+
+ /* If `preprocessor' directive, do the include. */
+ if (strncmp (buffer + i, "$include ", 9) == 0)
+ {
+ char *incfile, *t;
+
+ /* Find start of filename. */
+ for (incfile = buffer + i + 9; *incfile && whitespace (*incfile); incfile++)
+ ;
+
+ /* Find end of filename. */
+ for (t = incfile; *t && cr_whitespace (*t) == 0; t++)
+ ;
+
+ *t = '\0';
+
+ snarf_hosts_from_file (incfile);
+ continue;
+ }
+
+ /* Skip internet address if present. */
+ if (DIGIT (buffer[i]))
+ for (; buffer[i] && cr_whitespace (buffer[i]) == 0; i++);
+
+ /* Gobble up names. Each name is separated with whitespace. */
+ while (buffer[i])
+ {
+ for (; cr_whitespace (buffer[i]); i++)
+ ;
+ if (buffer[i] == '\0' || buffer[i] == '#')
+ break;
+
+ /* Isolate the current word. */
+ for (start = i; buffer[i] && cr_whitespace (buffer[i]) == 0; i++)
+ ;
+ if (i == start)
+ continue;
+ strncpy (name, buffer + start, i - start);
+ name[i - start] = '\0';
+ add_host_name (name);
+ }
+ }
+ fclose (file);
+}
+
+/* Return the hostname list. */
+char **
+get_hostname_list ()
+{
+ if (hostname_list_initialized == 0)
+ initialize_hostname_list ();
+ return (hostname_list);
+}
+
+void
+clear_hostname_list ()
+{
+ register int i;
+
+ if (hostname_list_initialized == 0)
+ return;
+ for (i = 0; i < hostname_list_length; i++)
+ free (hostname_list[i]);
+ hostname_list_length = hostname_list_initialized = 0;
+}
+
+/* Return a NULL terminated list of hostnames which begin with TEXT.
+ Initialize the hostname list the first time if necessary.
+ The array is malloc ()'ed, but not the individual strings. */
+static char **
+hostnames_matching (text)
+ char *text;
+{
+ register int i, len, nmatch, rsize;
+ char **result;
+
+ if (hostname_list_initialized == 0)
+ initialize_hostname_list ();
+
+ if (hostname_list_initialized == 0)
+ return ((char **)NULL);
+
+ /* Special case. If TEXT consists of nothing, then the whole list is
+ what is desired. */
+ if (*text == '\0')
+ {
+ result = strvec_create (1 + hostname_list_length);
+ for (i = 0; i < hostname_list_length; i++)
+ result[i] = hostname_list[i];
+ result[i] = (char *)NULL;
+ return (result);
+ }
+
+ /* Scan until found, or failure. */
+ len = strlen (text);
+ result = (char **)NULL;
+ for (i = nmatch = rsize = 0; i < hostname_list_length; i++)
+ {
+ if (STREQN (text, hostname_list[i], len) == 0)
+ continue;
+
+ /* OK, it matches. Add it to the list. */
+ if (nmatch >= (rsize - 1))
+ {
+ rsize = (rsize + 16) - (rsize % 16);
+ result = strvec_resize (result, rsize);
+ }
+
+ result[nmatch++] = hostname_list[i];
+ }
+ if (nmatch)
+ result[nmatch] = (char *)NULL;
+ return (result);
+}
+
+/* The equivalent of the Korn shell C-o operate-and-get-next-history-line
+ editing command. */
+static int saved_history_line_to_use = -1;
+static int last_saved_history_line = -1;
+
+#define HISTORY_FULL() (history_is_stifled () && history_length >= history_max_entries)
+
+static int
+set_saved_history ()
+{
+ /* XXX - compensate for assumption that history was `shuffled' if it was
+ actually not. */
+ if (HISTORY_FULL () &&
+ hist_last_line_added == 0 &&
+ saved_history_line_to_use < history_length - 1)
+ saved_history_line_to_use++;
+
+ if (saved_history_line_to_use >= 0)
+ {
+ rl_get_previous_history (history_length - saved_history_line_to_use, 0);
+ last_saved_history_line = saved_history_line_to_use;
+ }
+ saved_history_line_to_use = -1;
+ rl_startup_hook = old_rl_startup_hook;
+ return (0);
+}
+
+static int
+operate_and_get_next (count, c)
+ int count, c;
+{
+ int where;
+
+ /* Accept the current line. */
+ rl_newline (1, c);
+
+ /* Find the current line, and find the next line to use. */
+ where = where_history ();
+
+ if (HISTORY_FULL () || (where >= history_length - 1))
+ saved_history_line_to_use = where;
+ else
+ saved_history_line_to_use = where + 1;
+
+ old_rl_startup_hook = rl_startup_hook;
+ rl_startup_hook = set_saved_history;
+
+ return 0;
+}
+
+/* This vi mode command causes VI_EDIT_COMMAND to be run on the current
+ command being entered (if no explicit argument is given), otherwise on
+ a command from the history file. */
+
+#define VI_EDIT_COMMAND "fc -e \"${VISUAL:-${EDITOR:-vi}}\""
+#define EMACS_EDIT_COMMAND "fc -e \"${VISUAL:-${EDITOR:-emacs}}\""
+#define POSIX_VI_EDIT_COMMAND "fc -e vi"
+
+static int
+edit_and_execute_command (count, c, editing_mode, edit_command)
+ int count, c, editing_mode;
+ char *edit_command;
+{
+ char *command, *metaval;
+ int r, rrs, metaflag;
+ sh_parser_state_t ps;
+
+ rrs = rl_readline_state;
+ saved_command_line_count = current_command_line_count;
+
+ /* Accept the current line. */
+ rl_newline (1, c);
+
+ if (rl_explicit_arg)
+ {
+ command = (char *)xmalloc (strlen (edit_command) + 8);
+ sprintf (command, "%s %d", edit_command, count);
+ }
+ else
+ {
+ /* Take the command we were just editing, add it to the history file,
+ then call fc to operate on it. We have to add a dummy command to
+ the end of the history because fc ignores the last command (assumes
+ it's supposed to deal with the command before the `fc'). */
+ /* This breaks down when using command-oriented history and are not
+ finished with the command, so we should not ignore the last command */
+ using_history ();
+ current_command_line_count++; /* for rl_newline above */
+ bash_add_history (rl_line_buffer);
+ current_command_line_count = 0; /* for dummy history entry */
+ bash_add_history ("");
+ history_lines_this_session++;
+ using_history ();
+ command = savestring (edit_command);
+ }
+
+ metaval = rl_variable_value ("input-meta");
+ metaflag = RL_BOOLEAN_VARIABLE_VALUE (metaval);
+
+ /* Now, POSIX.1-2001 and SUSv3 say that the commands executed from the
+ temporary file should be placed into the history. We don't do that
+ yet. */
+ if (rl_deprep_term_function)
+ (*rl_deprep_term_function) ();
+ save_parser_state (&ps);
+ r = parse_and_execute (command, (editing_mode == VI_EDITING_MODE) ? "v" : "C-xC-e", SEVAL_NOHIST);
+ restore_parser_state (&ps);
+ if (rl_prep_term_function)
+ (*rl_prep_term_function) (metaflag);
+
+ current_command_line_count = saved_command_line_count;
+
+ /* Now erase the contents of the current line and undo the effects of the
+ rl_accept_line() above. We don't even want to make the text we just
+ executed available for undoing. */
+ rl_line_buffer[0] = '\0'; /* XXX */
+ rl_point = rl_end = 0;
+ rl_done = 0;
+ rl_readline_state = rrs;
+
+ rl_forced_update_display ();
+
+ return r;
+}
+
+#if defined (VI_MODE)
+static int
+vi_edit_and_execute_command (count, c)
+ int count, c;
+{
+ if (posixly_correct)
+ return (edit_and_execute_command (count, c, VI_EDITING_MODE, POSIX_VI_EDIT_COMMAND));
+ else
+ return (edit_and_execute_command (count, c, VI_EDITING_MODE, VI_EDIT_COMMAND));
+}
+#endif /* VI_MODE */
+
+static int
+emacs_edit_and_execute_command (count, c)
+ int count, c;
+{
+ return (edit_and_execute_command (count, c, EMACS_EDITING_MODE, EMACS_EDIT_COMMAND));
+}
+
+#if defined (ALIAS)
+static int
+posix_edit_macros (count, key)
+ int count, key;
+{
+ int c;
+ char alias_name[3], *alias_value, *macro;
+
+ c = rl_read_key ();
+ alias_name[0] = '_';
+ alias_name[1] = c;
+ alias_name[2] = '\0';
+
+ alias_value = get_alias_value (alias_name);
+ if (alias_value && *alias_value)
+ {
+ macro = savestring (alias_value);
+ rl_push_macro_input (macro);
+ }
+ return 0;
+}
+#endif
+
+/* Bindable commands that move `shell-words': that is, sequences of
+ non-unquoted-metacharacters. */
+
+#define WORDDELIM(c) (shellmeta(c) || shellblank(c))
+
+static int
+bash_forward_shellword (count, key)
+ int count, key;
+{
+ size_t slen;
+ int sindex, c, p;
+ DECLARE_MBSTATE;
+
+ if (count < 0)
+ return (bash_backward_shellword (-count, key));
+
+ /* The tricky part of this is deciding whether or not the first character
+ we're on is an unquoted metacharacter. Not completely handled yet. */
+ /* XXX - need to test this stuff with backslash-escaped shell
+ metacharacters and unclosed single- and double-quoted strings. */
+
+ p = rl_point;
+ slen = rl_end;
+
+ while (count)
+ {
+ if (p == rl_end)
+ {
+ rl_point = rl_end;
+ return 0;
+ }
+
+ /* Are we in a quoted string? If we are, move to the end of the quoted
+ string and continue the outer loop. We only want quoted strings, not
+ backslash-escaped characters, but char_is_quoted doesn't
+ differentiate. */
+ if (char_is_quoted (rl_line_buffer, p) && p > 0 && rl_line_buffer[p-1] != '\\')
+ {
+ do
+ ADVANCE_CHAR (rl_line_buffer, slen, p);
+ while (p < rl_end && char_is_quoted (rl_line_buffer, p));
+ count--;
+ continue;
+ }
+
+ /* Rest of code assumes we are not in a quoted string. */
+ /* Move forward until we hit a non-metacharacter. */
+ while (p < rl_end && (c = rl_line_buffer[p]) && WORDDELIM (c))
+ {
+ switch (c)
+ {
+ default:
+ ADVANCE_CHAR (rl_line_buffer, slen, p);
+ continue; /* straight back to loop, don't increment p */
+ case '\\':
+ if (p < rl_end && rl_line_buffer[p])
+ ADVANCE_CHAR (rl_line_buffer, slen, p);
+ break;
+ case '\'':
+ p = skip_to_delim (rl_line_buffer, ++p, "'", SD_NOJMP);
+ break;
+ case '"':
+ p = skip_to_delim (rl_line_buffer, ++p, "\"", SD_NOJMP);
+ break;
+ }
+
+ if (p < rl_end)
+ p++;
+ }
+
+ if (rl_line_buffer[p] == 0 || p == rl_end)
+ {
+ rl_point = rl_end;
+ rl_ding ();
+ return 0;
+ }
+
+ /* Now move forward until we hit a non-quoted metacharacter or EOL */
+ while (p < rl_end && (c = rl_line_buffer[p]) && WORDDELIM (c) == 0)
+ {
+ switch (c)
+ {
+ default:
+ ADVANCE_CHAR (rl_line_buffer, slen, p);
+ continue; /* straight back to loop, don't increment p */
+ case '\\':
+ if (p < rl_end && rl_line_buffer[p])
+ ADVANCE_CHAR (rl_line_buffer, slen, p);
+ break;
+ case '\'':
+ p = skip_to_delim (rl_line_buffer, ++p, "'", SD_NOJMP);
+ break;
+ case '"':
+ p = skip_to_delim (rl_line_buffer, ++p, "\"", SD_NOJMP);
+ break;
+ }
+
+ if (p < rl_end)
+ p++;
+ }
+
+ if (p == rl_end || rl_line_buffer[p] == 0)
+ {
+ rl_point = rl_end;
+ return (0);
+ }
+
+ count--;
+ }
+
+ rl_point = p;
+ return (0);
+}
+
+static int
+bash_backward_shellword (count, key)
+ int count, key;
+{
+ size_t slen;
+ int sindex, c, p;
+ DECLARE_MBSTATE;
+
+ if (count < 0)
+ return (bash_forward_shellword (-count, key));
+
+ p = rl_point;
+ slen = rl_end;
+
+ while (count)
+ {
+ if (p == 0)
+ {
+ rl_point = 0;
+ return 0;
+ }
+
+ /* Move backward until we hit a non-metacharacter. */
+ while (p > 0)
+ {
+ c = rl_line_buffer[p];
+ if (WORDDELIM (c) && char_is_quoted (rl_line_buffer, p) == 0)
+ BACKUP_CHAR (rl_line_buffer, slen, p);
+ break;
+ }
+
+ if (p == 0)
+ {
+ rl_point = 0;
+ return 0;
+ }
+
+ /* Now move backward until we hit a metacharacter or BOL. */
+ while (p > 0)
+ {
+ c = rl_line_buffer[p];
+ if (WORDDELIM (c) && char_is_quoted (rl_line_buffer, p) == 0)
+ break;
+ BACKUP_CHAR (rl_line_buffer, slen, p);
+ }
+
+ count--;
+ }
+
+ rl_point = p;
+ return 0;
+}
+
+static int
+bash_kill_shellword (count, key)
+ int count, key;
+{
+ int p;
+
+ if (count < 0)
+ return (bash_backward_kill_shellword (-count, key));
+
+ p = rl_point;
+ bash_forward_shellword (count, key);
+
+ if (rl_point != p)
+ rl_kill_text (p, rl_point);
+
+ rl_point = p;
+ if (rl_editing_mode == 1) /* 1 == emacs_mode */
+ rl_mark = rl_point;
+
+ return 0;
+}
+
+static int
+bash_backward_kill_shellword (count, key)
+ int count, key;
+{
+ int p;
+
+ if (count < 0)
+ return (bash_kill_shellword (-count, key));
+
+ p = rl_point;
+ bash_backward_shellword (count, key);
+
+ if (rl_point != p)
+ rl_kill_text (p, rl_point);
+
+ if (rl_editing_mode == 1) /* 1 == emacs_mode */
+ rl_mark = rl_point;
+
+ return 0;
+}
+
+
+/* **************************************************************** */
+/* */
+/* How To Do Shell Completion */
+/* */
+/* **************************************************************** */
+
+#define COMMAND_SEPARATORS ";|&{(`"
+/* )} */
+#define COMMAND_SEPARATORS_PLUS_WS ";|&{(` \t"
+/* )} */
+
+/* check for redirections and other character combinations that are not
+ command separators */
+static int
+check_redir (ti)
+ int ti;
+{
+ register int this_char, prev_char;
+
+ /* Handle the two character tokens `>&', `<&', and `>|'.
+ We are not in a command position after one of these. */
+ this_char = rl_line_buffer[ti];
+ prev_char = rl_line_buffer[ti - 1];
+
+ if ((this_char == '&' && (prev_char == '<' || prev_char == '>')) ||
+ (this_char == '|' && prev_char == '>'))
+ return (1);
+ else if (this_char == '{' && prev_char == '$') /*}*/
+ return (1);
+#if 0 /* Not yet */
+ else if (this_char == '(' && prev_char == '$') /*)*/
+ return (1);
+ else if (this_char == '(' && prev_char == '<') /*)*/
+ return (1);
+#if defined (EXTENDED_GLOB)
+ else if (extended_glob && this_char == '(' && prev_char == '!') /*)*/
+ return (1);
+#endif
+#endif
+ else if (char_is_quoted (rl_line_buffer, ti))
+ return (1);
+ return (0);
+}
+
+#if defined (PROGRAMMABLE_COMPLETION)
+/*
+ * XXX - because of the <= start test, and setting os = s+1, this can
+ * potentially return os > start. This is probably not what we want to
+ * happen, but fix later after 2.05a-release.
+ */
+static int
+find_cmd_start (start)
+ int start;
+{
+ register int s, os;
+
+ os = 0;
+ /* Flags == SD_NOJMP only because we want to skip over command substitutions
+ in assignment statements. Have to test whether this affects `standalone'
+ command substitutions as individual words. */
+ while (((s = skip_to_delim (rl_line_buffer, os, COMMAND_SEPARATORS, SD_NOJMP/*|SD_NOSKIPCMD*/)) <= 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, SD_NOJMP);
+ return e;
+}
+
+static char *
+find_cmd_name (start, sp, ep)
+ int start;
+ int *sp, *ep;
+{
+ char *name;
+ register int s, e;
+
+ for (s = start; whitespace (rl_line_buffer[s]); s++)
+ ;
+
+ /* skip until a shell break character */
+ e = skip_to_delim (rl_line_buffer, s, "()<>;&| \t\n", SD_NOJMP);
+
+ name = substring (rl_line_buffer, s, e);
+
+ if (sp)
+ *sp = s;
+ if (ep)
+ *ep = e;
+
+ return (name);
+}
+
+static char *
+prog_complete_return (text, matchnum)
+ const char *text;
+ int matchnum;
+{
+ static int ind;
+
+ if (matchnum == 0)
+ ind = 0;
+
+ if (prog_complete_matches == 0 || prog_complete_matches[ind] == 0)
+ return (char *)NULL;
+ return (prog_complete_matches[ind++]);
+}
+
+#endif /* PROGRAMMABLE_COMPLETION */
+
+/* Try and catch completion attempts that are syntax errors or otherwise
+ invalid. */
+static int
+invalid_completion (text, ind)
+ const char *text;
+ int ind;
+{
+ int pind;
+
+ /* If we don't catch these here, the next clause will */
+ if (ind > 0 && rl_line_buffer[ind] == '(' && /*)*/
+ member (rl_line_buffer[ind-1], "$<>"))
+ return 0;
+
+ pind = ind - 1;
+ while (pind > 0 && whitespace (rl_line_buffer[pind]))
+ pind--;
+ /* If we have only whitespace preceding a paren, it's valid */
+ if (ind >= 0 && pind <= 0 && rl_line_buffer[ind] == '(') /*)*/
+ return 0;
+ /* Flag the invalid completions, which are mostly syntax errors */
+ if (ind > 0 && rl_line_buffer[ind] == '(' && /*)*/
+ member (rl_line_buffer[pind], COMMAND_SEPARATORS) == 0)
+ return 1;
+
+ return 0;
+}
+
+/* Do some completion on TEXT. The indices of TEXT in RL_LINE_BUFFER are
+ at START and END. Return an array of matches, or NULL if none. */
+static char **
+attempt_shell_completion (text, start, end)
+ const char *text;
+ int start, end;
+{
+ int in_command_position, ti, saveti, qc, dflags;
+ char **matches, *command_separator_chars;
+#if defined (PROGRAMMABLE_COMPLETION)
+ int have_progcomps, was_assignment;
+#endif
+
+ command_separator_chars = COMMAND_SEPARATORS;
+ matches = (char **)NULL;
+ rl_ignore_some_completions_function = filename_completion_ignore;
+
+ rl_filename_quote_characters = default_filename_quote_characters;
+ set_filename_bstab (rl_filename_quote_characters);
+ set_directory_hook ();
+ rl_filename_stat_hook = bash_filename_stat_hook;
+
+ /* Determine if this could be a command word. It is if it appears at
+ the start of the line (ignoring preceding whitespace), or if it
+ appears after a character that separates commands. It cannot be a
+ command word if we aren't at the top-level prompt. */
+ ti = start - 1;
+ saveti = qc = -1;
+
+ while ((ti > -1) && (whitespace (rl_line_buffer[ti])))
+ ti--;
+
+#if 1
+ /* If this is an open quote, maybe we're trying to complete a quoted
+ command name. */
+ if (ti >= 0 && (rl_line_buffer[ti] == '"' || rl_line_buffer[ti] == '\''))
+ {
+ qc = rl_line_buffer[ti];
+ saveti = ti--;
+ while (ti > -1 && (whitespace (rl_line_buffer[ti])))
+ ti--;
+ }
+#endif
+
+ in_command_position = 0;
+ if (ti < 0)
+ {
+ /* Only do command completion at the start of a line when we
+ are prompting at the top level. */
+ if (current_prompt_string == ps1_prompt)
+ in_command_position++;
+ else if (parser_in_command_position ())
+ in_command_position++;
+ }
+ else if (member (rl_line_buffer[ti], command_separator_chars))
+ {
+ in_command_position++;
+
+ if (check_redir (ti) == 1)
+ in_command_position = 0;
+ }
+ else
+ {
+ /* This still could be in command position. It is possible
+ that all of the previous words on the line are variable
+ assignments. */
+ }
+
+ if (in_command_position && invalid_completion (text, ti))
+ {
+ rl_attempted_completion_over = 1;
+ return ((char **)NULL);
+ }
+
+ /* Check that we haven't incorrectly flagged a closed command substitution
+ as indicating we're in a command position. */
+ if (in_command_position && ti >= 0 && rl_line_buffer[ti] == '`' &&
+ *text != '`' && unclosed_pair (rl_line_buffer, end, "`") == 0)
+ in_command_position = 0;
+
+ /* Special handling for command substitution. If *TEXT is a backquote,
+ it can be the start or end of an old-style command substitution, or
+ unmatched. If it's unmatched, both calls to unclosed_pair will
+ succeed. Don't bother if readline found a single quote and we are
+ completing on the substring. */
+ if (*text == '`' && rl_completion_quote_character != '\'' &&
+ (in_command_position || (unclosed_pair (rl_line_buffer, start, "`") &&
+ unclosed_pair (rl_line_buffer, end, "`"))))
+ matches = rl_completion_matches (text, command_subst_completion_function);
+
+#if defined (PROGRAMMABLE_COMPLETION)
+ /* Attempt programmable completion. */
+ have_progcomps = prog_completion_enabled && (progcomp_size () > 0);
+ if (matches == 0 && (in_command_position == 0 || text[0] == '\0') &&
+ current_prompt_string == ps1_prompt)
+ {
+ int s, e, s1, e1, os, foundcs;
+ char *n;
+
+ /* XXX - don't free the members */
+ if (prog_complete_matches)
+ free (prog_complete_matches);
+ prog_complete_matches = (char **)NULL;
+
+ os = start;
+ n = 0;
+ s = find_cmd_start (os);
+ e = find_cmd_end (end);
+ do
+ {
+ /* Skip over assignment statements preceding a command name. If we
+ don't find a command name at all, we can perform command name
+ completion. If we find a partial command name, we should perform
+ command name completion on it. */
+ FREE (n);
+ n = find_cmd_name (s, &s1, &e1);
+ s = e1 + 1;
+ }
+ while (was_assignment = assignment (n, 0));
+ s = s1; /* reset to index where name begins */
+
+ /* s == index of where command name begins (reset above)
+ e == end of current command, may be end of line
+ s1 = index of where command name begins
+ e1 == index of where command name ends
+ start == index of where word to be completed begins
+ end == index of where word to be completed ends
+ if (s == start) we are doing command word completion for sure
+ if (e1 == end) we are at the end of the command name and completing it */
+ if (start == 0 && end == 0 && e != 0 && text[0] == '\0') /* beginning of non-empty line */
+ foundcs = 0;
+ else if (start == end && start == s1 && e != 0 && e1 > end) /* beginning of command name, leading whitespace */
+ foundcs = 0;
+ else if (e == 0 && e == s && text[0] == '\0' && have_progcomps) /* beginning of empty line */
+ prog_complete_matches = programmable_completions ("_EmptycmD_", text, s, e, &foundcs);
+ else if (start == end && text[0] == '\0' && s1 > start && whitespace (rl_line_buffer[start]))
+ foundcs = 0; /* whitespace before command name */
+ else if (e > s && was_assignment == 0 && e1 == end && rl_line_buffer[e] == 0 && whitespace (rl_line_buffer[e-1]) == 0)
+ {
+ /* not assignment statement, but still want to perform command
+ completion if we are composing command word. */
+ foundcs = 0;
+ in_command_position = s == start && STREQ (n, text); /* XXX */
+ }
+ else if (e > s && was_assignment == 0 && have_progcomps)
+ {
+ prog_complete_matches = programmable_completions (n, text, s, e, &foundcs);
+ /* command completion if programmable completion fails */
+ in_command_position = s == start && STREQ (n, text); /* XXX */
+ }
+ /* empty command name following command separator */
+ else if (s >= e && n[0] == '\0' && text[0] == '\0' && start > 0 &&
+ was_assignment == 0 && member (rl_line_buffer[start-1], COMMAND_SEPARATORS))
+ {
+ foundcs = 0;
+ in_command_position = 1;
+ }
+ else if (s >= e && n[0] == '\0' && text[0] == '\0' && start > 0)
+ {
+ foundcs = 0; /* empty command name following assignments */
+ in_command_position = was_assignment;
+ }
+ else if (s == start && e == end && STREQ (n, text) && start > 0)
+ {
+ foundcs = 0; /* partial command name following assignments */
+ in_command_position = 1;
+ }
+ else
+ foundcs = 0;
+ FREE (n);
+ /* XXX - if we found a COMPSPEC for the command, just return whatever
+ the programmable completion code returns, and disable the default
+ filename completion that readline will do unless the COPT_DEFAULT
+ option has been set with the `-o default' option to complete or
+ compopt. */
+ if (foundcs)
+ {
+ pcomp_set_readline_variables (foundcs, 1);
+ /* Turn what the programmable completion code returns into what
+ readline wants. I should have made compute_lcd_of_matches
+ external... */
+ matches = rl_completion_matches (text, prog_complete_return);
+ if ((foundcs & COPT_DEFAULT) == 0)
+ rl_attempted_completion_over = 1; /* no default */
+ if (matches || ((foundcs & COPT_BASHDEFAULT) == 0))
+ return (matches);
+ }
+ }
+#endif
+
+ if (matches == 0)
+ {
+ dflags = 0;
+ if (in_command_position)
+ dflags |= DEFCOMP_CMDPOS;
+ matches = bash_default_completion (text, start, end, qc, dflags);
+ }
+
+ return matches;
+}
+
+char **
+bash_default_completion (text, start, end, qc, compflags)
+ const char *text;
+ int start, end, qc, compflags;
+{
+ char **matches, *t;
+
+ matches = (char **)NULL;
+
+ /* New posix-style command substitution or variable name? */
+ if (!matches && *text == '$')
+ {
+ if (qc != '\'' && text[1] == '(') /* ) */
+ matches = rl_completion_matches (text, command_subst_completion_function);
+ else
+ {
+ matches = rl_completion_matches (text, variable_completion_function);
+ if (matches && matches[0] && matches[1] == 0)
+ {
+ t = savestring (matches[0]);
+ bash_filename_stat_hook (&t);
+ /* doesn't use test_for_directory because that performs tilde
+ expansion */
+ if (file_isdir (t))
+ rl_completion_append_character = '/';
+ free (t);
+ }
+ }
+ }
+
+ /* If the word starts in `~', and there is no slash in the word, then
+ try completing this word as a username. */
+ if (matches == 0 && *text == '~' && mbschr (text, '/') == 0)
+ matches = rl_completion_matches (text, rl_username_completion_function);
+
+ /* Another one. Why not? If the word starts in '@', then look through
+ the world of known hostnames for completion first. */
+ if (matches == 0 && perform_hostname_completion && *text == '@')
+ matches = rl_completion_matches (text, hostname_completion_function);
+
+ /* And last, (but not least) if this word is in a command position, then
+ complete over possible command names, including aliases, functions,
+ and command names. */
+ if (matches == 0 && (compflags & DEFCOMP_CMDPOS))
+ {
+ /* If END == START and text[0] == 0, we are trying to complete an empty
+ command word. */
+ if (no_empty_command_completion && end == start && text[0] == '\0')
+ {
+ matches = (char **)NULL;
+ rl_ignore_some_completions_function = bash_ignore_everything;
+ }
+ else
+ {
+#define CMD_IS_DIR(x) (absolute_pathname(x) == 0 && absolute_program(x) == 0 && *(x) != '~' && test_for_directory (x))
+
+ dot_in_path = 0;
+ matches = rl_completion_matches (text, command_word_completion_function);
+
+ /* If we are attempting command completion and nothing matches, we
+ do not want readline to perform filename completion for us. We
+ still want to be able to complete partial pathnames, so set the
+ completion ignore function to something which will remove
+ filenames and leave directories in the match list. */
+ if (matches == (char **)NULL)
+ rl_ignore_some_completions_function = bash_ignore_filenames;
+ else if (matches[1] == 0 && CMD_IS_DIR(matches[0]) && dot_in_path == 0)
+ /* If we found a single match, without looking in the current
+ directory (because it's not in $PATH), but the found name is
+ also a command in the current directory, suppress appending any
+ terminating character, since it's ambiguous. */
+ {
+ rl_completion_suppress_append = 1;
+ rl_filename_completion_desired = 0;
+ }
+ else if (matches[0] && matches[1] && STREQ (matches[0], matches[1]) && CMD_IS_DIR (matches[0]))
+ /* There are multiple instances of the same match (duplicate
+ completions haven't yet been removed). In this case, all of
+ the matches will be the same, and the duplicate removal code
+ will distill them all down to one. We turn on
+ rl_completion_suppress_append for the same reason as above.
+ Remember: we only care if there's eventually a single unique
+ completion. If there are multiple completions this won't
+ make a difference and the problem won't occur. */
+ {
+ rl_completion_suppress_append = 1;
+ rl_filename_completion_desired = 0;
+ }
+ }
+ }
+
+ /* This could be a globbing pattern, so try to expand it using pathname
+ expansion. */
+ if (!matches && glob_pattern_p (text))
+ {
+ matches = rl_completion_matches (text, glob_complete_word);
+ /* A glob expression that matches more than one filename is problematic.
+ If we match more than one filename, punt. */
+ if (matches && matches[1] && rl_completion_type == TAB)
+ {
+ strvec_dispose (matches);
+ matches = (char **)0;
+ }
+ else if (matches && matches[1] && rl_completion_type == '!')
+ {
+ rl_completion_suppress_append = 1;
+ rl_filename_completion_desired = 0;
+ }
+ }
+
+ return (matches);
+}
+
+static int
+bash_command_name_stat_hook (name)
+ char **name;
+{
+ char *cname, *result;
+
+ /* If it's not something we're going to look up in $PATH, just call the
+ normal filename stat hook. */
+ if (absolute_program (*name))
+ return (bash_filename_stat_hook (name));
+
+ cname = *name;
+ /* XXX - we could do something here with converting aliases, builtins,
+ and functions into something that came out as executable, but we don't. */
+ result = search_for_command (cname, 0);
+ if (result)
+ {
+ *name = result;
+ return 1;
+ }
+ return 0;
+}
+
+static int
+executable_completion (filename, searching_path)
+ const char *filename;
+ int searching_path;
+{
+ char *f;
+ int r;
+
+ f = savestring (filename);
+ bash_directory_completion_hook (&f);
+
+ r = searching_path ? executable_file (f) : executable_or_directory (f);
+ free (f);
+ return r;
+}
+
+/* This is the function to call when the word to complete is in a position
+ where a command word can be found. It grovels $PATH, looking for commands
+ that match. It also scans aliases, function names, and the shell_builtin
+ table. */
+char *
+command_word_completion_function (hint_text, state)
+ const char *hint_text;
+ int state;
+{
+ static char *hint = (char *)NULL;
+ static char *path = (char *)NULL;
+ static char *val = (char *)NULL;
+ static char *filename_hint = (char *)NULL;
+ static char *fnhint = (char *)NULL;
+ static char *dequoted_hint = (char *)NULL;
+ static char *directory_part = (char *)NULL;
+ static char **glob_matches = (char **)NULL;
+ static int path_index, hint_len, dequoted_len, istate, igncase;
+ static int mapping_over, local_index, searching_path, hint_is_dir;
+ static int old_glob_ignore_case, globpat;
+ static SHELL_VAR **varlist = (SHELL_VAR **)NULL;
+#if defined (ALIAS)
+ static alias_t **alias_list = (alias_t **)NULL;
+#endif /* ALIAS */
+ char *temp, *cval;
+
+ /* We have to map over the possibilities for command words. If we have
+ no state, then make one just for that purpose. */
+ if (state == 0)
+ {
+ rl_filename_stat_hook = bash_command_name_stat_hook;
+
+ if (dequoted_hint && dequoted_hint != hint)
+ free (dequoted_hint);
+ if (hint)
+ free (hint);
+
+ mapping_over = searching_path = 0;
+ hint_is_dir = CMD_IS_DIR (hint_text);
+ val = (char *)NULL;
+
+ temp = rl_variable_value ("completion-ignore-case");
+ igncase = RL_BOOLEAN_VARIABLE_VALUE (temp);
+
+ if (glob_matches)
+ {
+ free (glob_matches);
+ glob_matches = (char **)NULL;
+ }
+
+ globpat = glob_pattern_p (hint_text);
+
+ /* If this is an absolute program name, do not check it against
+ aliases, reserved words, functions or builtins. We must check
+ whether or not it is unique, and, if so, whether that filename
+ is executable. */
+ if (globpat || absolute_program (hint_text))
+ {
+ /* Perform tilde expansion on what's passed, so we don't end up
+ passing filenames with tildes directly to stat(). */
+ if (*hint_text == '~')
+ {
+ hint = bash_tilde_expand (hint_text, 0);
+ directory_part = savestring (hint_text);
+ temp = strchr (directory_part, '/');
+ if (temp)
+ *temp = 0;
+ else
+ {
+ free (directory_part);
+ directory_part = (char *)NULL;
+ }
+ }
+ else
+ hint = savestring (hint_text);
+
+ dequoted_hint = hint;
+ /* If readline's completer found a quote character somewhere, but
+ didn't set the quote character, there must have been a quote
+ character embedded in the filename. It can't be at the start of
+ the filename, so we need to dequote the filename before we look
+ in the file system for it. */
+ if (rl_completion_found_quote && rl_completion_quote_character == 0)
+ {
+ dequoted_hint = bash_dequote_filename (hint, 0);
+ free (hint);
+ hint = dequoted_hint;
+ }
+ dequoted_len = hint_len = strlen (hint);
+
+ if (filename_hint)
+ free (filename_hint);
+
+ fnhint = filename_hint = savestring (hint);
+
+ istate = 0;
+
+ if (globpat)
+ {
+ mapping_over = 5;
+ goto globword;
+ }
+ else
+ {
+ if (dircomplete_expand && path_dot_or_dotdot (filename_hint))
+ {
+ dircomplete_expand = 0;
+ set_directory_hook ();
+ dircomplete_expand = 1;
+ }
+ mapping_over = 4;
+ goto inner;
+ }
+ }
+
+ dequoted_hint = hint = savestring (hint_text);
+ dequoted_len = hint_len = strlen (hint);
+
+ if (rl_completion_found_quote && rl_completion_quote_character == 0)
+ {
+ dequoted_hint = bash_dequote_filename (hint, 0);
+ dequoted_len = strlen (dequoted_hint);
+ }
+
+ path = get_string_value ("PATH");
+ path_index = dot_in_path = 0;
+
+ /* Initialize the variables for each type of command word. */
+ local_index = 0;
+
+ if (varlist)
+ free (varlist);
+
+ varlist = all_visible_functions ();
+
+#if defined (ALIAS)
+ if (alias_list)
+ free (alias_list);
+
+ alias_list = all_aliases ();
+#endif /* ALIAS */
+ }
+
+ /* mapping_over says what we are currently hacking. Note that every case
+ in this list must fall through when there are no more possibilities. */
+
+ switch (mapping_over)
+ {
+ case 0: /* Aliases come first. */
+#if defined (ALIAS)
+ while (alias_list && alias_list[local_index])
+ {
+ register char *alias;
+
+ alias = alias_list[local_index++]->name;
+
+ if (STREQN (alias, hint, hint_len))
+ return (savestring (alias));
+ }
+#endif /* ALIAS */
+ local_index = 0;
+ mapping_over++;
+
+ case 1: /* Then shell reserved words. */
+ {
+ while (word_token_alist[local_index].word)
+ {
+ register char *reserved_word;
+
+ reserved_word = word_token_alist[local_index++].word;
+
+ if (STREQN (reserved_word, hint, hint_len))
+ return (savestring (reserved_word));
+ }
+ local_index = 0;
+ mapping_over++;
+ }
+
+ case 2: /* Then function names. */
+ while (varlist && varlist[local_index])
+ {
+ register char *varname;
+
+ varname = varlist[local_index++]->name;
+
+ if (STREQN (varname, hint, hint_len))
+ return (savestring (varname));
+ }
+ local_index = 0;
+ mapping_over++;
+
+ case 3: /* Then shell builtins. */
+ for (; local_index < num_shell_builtins; local_index++)
+ {
+ /* Ignore it if it doesn't have a function pointer or if it
+ is not currently enabled. */
+ if (!shell_builtins[local_index].function ||
+ (shell_builtins[local_index].flags & BUILTIN_ENABLED) == 0)
+ continue;
+
+ if (STREQN (shell_builtins[local_index].name, hint, hint_len))
+ {
+ int i = local_index++;
+
+ return (savestring (shell_builtins[i].name));
+ }
+ }
+ local_index = 0;
+ mapping_over++;
+ }
+
+globword:
+ /* Limited support for completing command words with globbing chars. Only
+ a single match (multiple matches that end up reducing the number of
+ characters in the common prefix are bad) will ever be returned on
+ regular completion. */
+ if (globpat)
+ {
+ if (state == 0)
+ {
+ glob_ignore_case = igncase;
+ glob_matches = shell_glob_filename (hint);
+ glob_ignore_case = old_glob_ignore_case;
+
+ if (GLOB_FAILED (glob_matches) || glob_matches == 0)
+ {
+ glob_matches = (char **)NULL;
+ return ((char *)NULL);
+ }
+
+ local_index = 0;
+
+ if (glob_matches[1] && rl_completion_type == TAB) /* multiple matches are bad */
+ return ((char *)NULL);
+ }
+
+ while (val = glob_matches[local_index++])
+ {
+ if (executable_or_directory (val))
+ {
+ if (*hint_text == '~' && directory_part)
+ {
+ temp = maybe_restore_tilde (val, directory_part);
+ free (val);
+ val = temp;
+ }
+ return (val);
+ }
+ free (val);
+ }
+
+ glob_ignore_case = old_glob_ignore_case;
+ return ((char *)NULL);
+ }
+
+ /* If the text passed is a directory in the current directory, return it
+ as a possible match. Executables in directories in the current
+ directory can be specified using relative pathnames and successfully
+ executed even when `.' is not in $PATH. */
+ if (hint_is_dir)
+ {
+ hint_is_dir = 0; /* only return the hint text once */
+ return (savestring (hint_text));
+ }
+
+ /* Repeatedly call filename_completion_function while we have
+ members of PATH left. Question: should we stat each file?
+ Answer: we call executable_file () on each file. */
+ outer:
+
+ istate = (val != (char *)NULL);
+
+ if (istate == 0)
+ {
+ char *current_path;
+
+ /* Get the next directory from the path. If there is none, then we
+ are all done. */
+ if (path == 0 || path[path_index] == 0 ||
+ (current_path = extract_colon_unit (path, &path_index)) == 0)
+ return ((char *)NULL);
+
+ searching_path = 1;
+ if (*current_path == 0)
+ {
+ free (current_path);
+ current_path = savestring (".");
+ }
+
+ if (*current_path == '~')
+ {
+ char *t;
+
+ t = bash_tilde_expand (current_path, 0);
+ free (current_path);
+ current_path = t;
+ }
+
+ if (current_path[0] == '.' && current_path[1] == '\0')
+ dot_in_path = 1;
+
+ if (fnhint && fnhint != filename_hint)
+ free (fnhint);
+ if (filename_hint)
+ free (filename_hint);
+
+ filename_hint = sh_makepath (current_path, hint, 0);
+ /* Need a quoted version (though it doesn't matter much in most
+ cases) because rl_filename_completion_function dequotes the
+ filename it gets, assuming that it's been quoted as part of
+ the input line buffer. */
+ if (strpbrk (filename_hint, "\"'\\"))
+ fnhint = sh_backslash_quote (filename_hint, filename_bstab, 0);
+ else
+ fnhint = filename_hint;
+ free (current_path); /* XXX */
+ }
+
+ inner:
+ val = rl_filename_completion_function (fnhint, istate);
+ if (mapping_over == 4 && dircomplete_expand)
+ set_directory_hook ();
+
+ istate = 1;
+
+ if (val == 0)
+ {
+ /* If the hint text is an absolute program, then don't bother
+ searching through PATH. */
+ if (absolute_program (hint))
+ return ((char *)NULL);
+
+ goto outer;
+ }
+ else
+ {
+ int match, freetemp;
+
+ if (absolute_program (hint))
+ {
+ if (igncase == 0)
+ match = strncmp (val, hint, hint_len) == 0;
+ else
+ match = strncasecmp (val, hint, hint_len) == 0;
+
+ /* If we performed tilde expansion, restore the original
+ filename. */
+ if (*hint_text == '~')
+ temp = maybe_restore_tilde (val, directory_part);
+ else
+ temp = savestring (val);
+ freetemp = 1;
+ }
+ else
+ {
+ temp = strrchr (val, '/');
+
+ if (temp)
+ {
+ temp++;
+ if (igncase == 0)
+ freetemp = match = strncmp (temp, hint, hint_len) == 0;
+ else
+ freetemp = match = strncasecmp (temp, hint, hint_len) == 0;
+ if (match)
+ temp = savestring (temp);
+ }
+ else
+ freetemp = match = 0;
+ }
+
+ /* If we have found a match, and it is an executable file, return it.
+ We don't return directory names when searching $PATH, since the
+ bash execution code won't find executables in directories which
+ appear in directories in $PATH when they're specified using
+ relative pathnames. */
+#if 0
+ /* If we're not searching $PATH and we have a relative pathname, we
+ need to re-canonicalize it before testing whether or not it's an
+ executable or a directory so the shell treats .. relative to $PWD
+ according to the physical/logical option. The shell already
+ canonicalizes the directory name in order to tell readline where
+ to look, so not doing it here will be inconsistent. */
+ /* XXX -- currently not used -- will introduce more inconsistency,
+ since shell does not canonicalize ../foo before passing it to
+ shell_execve(). */
+ if (match && searching_path == 0 && *val == '.')
+ {
+ char *t, *t1;
+
+ t = get_working_directory ("command-word-completion");
+ t1 = make_absolute (val, t);
+ free (t);
+ cval = sh_canonpath (t1, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);
+ }
+ else
+#endif
+ cval = val;
+
+ if (match && executable_completion ((searching_path ? val : cval), searching_path))
+ {
+ if (cval != val)
+ free (cval);
+ free (val);
+ val = ""; /* So it won't be NULL. */
+ return (temp);
+ }
+ else
+ {
+ if (freetemp)
+ free (temp);
+ if (cval != val)
+ free (cval);
+ free (val);
+ goto inner;
+ }
+ }
+}
+
+/* Completion inside an unterminated command substitution. */
+static char *
+command_subst_completion_function (text, state)
+ const char *text;
+ int state;
+{
+ static char **matches = (char **)NULL;
+ static const char *orig_start;
+ static char *filename_text = (char *)NULL;
+ static int cmd_index, start_len;
+ char *value;
+
+ if (state == 0)
+ {
+ if (filename_text)
+ free (filename_text);
+ orig_start = text;
+ if (*text == '`')
+ text++;
+ else if (*text == '$' && text[1] == '(') /* ) */
+ text += 2;
+ /* If the text was quoted, suppress any quote character that the
+ readline completion code would insert. */
+ rl_completion_suppress_quote = 1;
+ start_len = text - orig_start;
+ filename_text = savestring (text);
+ if (matches)
+ free (matches);
+
+ /*
+ * At this point we can entertain the idea of re-parsing
+ * `filename_text' into a (possibly incomplete) command name and
+ * arguments, and doing completion based on that. This is
+ * currently very rudimentary, but it is a small improvement.
+ */
+ for (value = filename_text + strlen (filename_text) - 1; value > filename_text; value--)
+ if (whitespace (*value) || member (*value, COMMAND_SEPARATORS))
+ break;
+ if (value <= filename_text)
+ matches = rl_completion_matches (filename_text, command_word_completion_function);
+ else
+ {
+ value++;
+ start_len += value - filename_text;
+ if (whitespace (value[-1]))
+ matches = rl_completion_matches (value, rl_filename_completion_function);
+ else
+ matches = rl_completion_matches (value, command_word_completion_function);
+ }
+
+ /* If there is more than one match, rl_completion_matches has already
+ put the lcd in matches[0]. Skip over it. */
+ cmd_index = matches && matches[0] && matches[1];
+
+ /* If there's a single match and it's a directory, set the append char
+ to the expected `/'. Otherwise, don't append anything. */
+ if (matches && matches[0] && matches[1] == 0 && test_for_directory (matches[0]))
+ rl_completion_append_character = '/';
+ else
+ rl_completion_suppress_append = 1;
+ }
+
+ if (matches == 0 || matches[cmd_index] == 0)
+ {
+ rl_filename_quoting_desired = 0; /* disable quoting */
+ return ((char *)NULL);
+ }
+ else
+ {
+ value = (char *)xmalloc (1 + start_len + strlen (matches[cmd_index]));
+
+ if (start_len == 1)
+ value[0] = *orig_start;
+ else
+ strncpy (value, orig_start, start_len);
+
+ strcpy (value + start_len, matches[cmd_index]);
+
+ cmd_index++;
+ return (value);
+ }
+}
+
+/* Okay, now we write the entry_function for variable completion. */
+static char *
+variable_completion_function (text, state)
+ const char *text;
+ int state;
+{
+ static char **varlist = (char **)NULL;
+ static int varlist_index;
+ static char *varname = (char *)NULL;
+ static int namelen;
+ static int first_char, first_char_loc;
+
+ if (!state)
+ {
+ if (varname)
+ free (varname);
+
+ first_char_loc = 0;
+ first_char = text[0];
+
+ if (first_char == '$')
+ first_char_loc++;
+
+ if (text[first_char_loc] == '{')
+ first_char_loc++;
+
+ varname = savestring (text + first_char_loc);
+
+ namelen = strlen (varname);
+ if (varlist)
+ strvec_dispose (varlist);
+
+ varlist = all_variables_matching_prefix (varname);
+ varlist_index = 0;
+ }
+
+ if (!varlist || !varlist[varlist_index])
+ {
+ return ((char *)NULL);
+ }
+ else
+ {
+ char *value;
+
+ value = (char *)xmalloc (4 + strlen (varlist[varlist_index]));
+
+ if (first_char_loc)
+ {
+ value[0] = first_char;
+ if (first_char_loc == 2)
+ value[1] = '{';
+ }
+
+ strcpy (value + first_char_loc, varlist[varlist_index]);
+ if (first_char_loc == 2)
+ strcat (value, "}");
+
+ varlist_index++;
+ return (value);
+ }
+}
+
+/* How about a completion function for hostnames? */
+static char *
+hostname_completion_function (text, state)
+ const char *text;
+ int state;
+{
+ static char **list = (char **)NULL;
+ static int list_index = 0;
+ static int first_char, first_char_loc;
+
+ /* If we don't have any state, make some. */
+ if (state == 0)
+ {
+ FREE (list);
+
+ list = (char **)NULL;
+
+ first_char_loc = 0;
+ first_char = *text;
+
+ if (first_char == '@')
+ first_char_loc++;
+
+ list = hostnames_matching ((char *)text+first_char_loc);
+ list_index = 0;
+ }
+
+ if (list && list[list_index])
+ {
+ char *t;
+
+ t = (char *)xmalloc (2 + strlen (list[list_index]));
+ *t = first_char;
+ strcpy (t + first_char_loc, list[list_index]);
+ list_index++;
+ return (t);
+ }
+
+ return ((char *)NULL);
+}
+
+/*
+ * A completion function for service names from /etc/services (or wherever).
+ */
+char *
+bash_servicename_completion_function (text, state)
+ const char *text;
+ int state;
+{
+#if defined (__WIN32__) || defined (__OPENNT) || !defined (HAVE_GETSERVENT)
+ return ((char *)NULL);
+#else
+ static char *sname = (char *)NULL;
+ static struct servent *srvent;
+ static int snamelen, firstc;
+ char *value;
+ char **alist, *aentry;
+ int afound;
+
+ if (state == 0)
+ {
+ FREE (sname);
+ firstc = *text;
+
+ sname = savestring (text);
+ snamelen = strlen (sname);
+ setservent (0);
+ }
+
+ while (srvent = getservent ())
+ {
+ afound = 0;
+ if (snamelen == 0 || (STREQN (sname, srvent->s_name, snamelen)))
+ break;
+ /* Not primary, check aliases */
+ for (alist = srvent->s_aliases; *alist; alist++)
+ {
+ aentry = *alist;
+ if (STREQN (sname, aentry, snamelen))
+ {
+ afound = 1;
+ break;
+ }
+ }
+
+ if (afound)
+ break;
+ }
+
+ if (srvent == 0)
+ {
+ endservent ();
+ return ((char *)NULL);
+ }
+
+ value = afound ? savestring (aentry) : savestring (srvent->s_name);
+ return value;
+#endif
+}
+
+/*
+ * A completion function for group names from /etc/group (or wherever).
+ */
+char *
+bash_groupname_completion_function (text, state)
+ const char *text;
+ int state;
+{
+#if defined (__WIN32__) || defined (__OPENNT) || !defined (HAVE_GRP_H)
+ return ((char *)NULL);
+#else
+ static char *gname = (char *)NULL;
+ static struct group *grent;
+ static int gnamelen;
+ char *value;
+
+ if (state == 0)
+ {
+ FREE (gname);
+ gname = savestring (text);
+ gnamelen = strlen (gname);
+
+ setgrent ();
+ }
+
+ while (grent = getgrent ())
+ {
+ if (gnamelen == 0 || (STREQN (gname, grent->gr_name, gnamelen)))
+ break;
+ }
+
+ if (grent == 0)
+ {
+ endgrent ();
+ return ((char *)NULL);
+ }
+
+ value = savestring (grent->gr_name);
+ return (value);
+#endif
+}
+
+/* Functions to perform history and alias expansions on the current line. */
+
+#if defined (BANG_HISTORY)
+/* Perform history expansion on the current line. If no history expansion
+ is done, pre_process_line() returns what it was passed, so we need to
+ allocate a new line here. */
+static char *
+history_expand_line_internal (line)
+ char *line;
+{
+ char *new_line;
+ int old_verify;
+
+ old_verify = hist_verify;
+ hist_verify = 0;
+ new_line = pre_process_line (line, 0, 0);
+ hist_verify = old_verify;
+
+ return (new_line == line) ? savestring (line) : new_line;
+}
+#endif
+
+/* There was an error in expansion. Let the preprocessor print
+ the error here. */
+static void
+cleanup_expansion_error ()
+{
+ char *to_free;
+#if defined (BANG_HISTORY)
+ int old_verify;
+
+ old_verify = hist_verify;
+ hist_verify = 0;
+#endif
+
+ fprintf (rl_outstream, "\r\n");
+ to_free = pre_process_line (rl_line_buffer, 1, 0);
+#if defined (BANG_HISTORY)
+ hist_verify = old_verify;
+#endif
+ if (to_free != rl_line_buffer)
+ FREE (to_free);
+ putc ('\r', rl_outstream);
+ rl_forced_update_display ();
+}
+
+/* If NEW_LINE differs from what is in the readline line buffer, add an
+ undo record to get from the readline line buffer contents to the new
+ line and make NEW_LINE the current readline line. */
+static void
+maybe_make_readline_line (new_line)
+ char *new_line;
+{
+ if (strcmp (new_line, rl_line_buffer) != 0)
+ {
+ rl_point = rl_end;
+
+ rl_add_undo (UNDO_BEGIN, 0, 0, 0);
+ rl_delete_text (0, rl_point);
+ rl_point = rl_end = rl_mark = 0;
+ rl_insert_text (new_line);
+ rl_add_undo (UNDO_END, 0, 0, 0);
+ }
+}
+
+/* Make NEW_LINE be the current readline line. This frees NEW_LINE. */
+static void
+set_up_new_line (new_line)
+ char *new_line;
+{
+ int old_point, at_end;
+
+ old_point = rl_point;
+ at_end = rl_point == rl_end;
+
+ /* If the line was history and alias expanded, then make that
+ be one thing to undo. */
+ maybe_make_readline_line (new_line);
+ free (new_line);
+
+ /* Place rl_point where we think it should go. */
+ if (at_end)
+ rl_point = rl_end;
+ else if (old_point < rl_end)
+ {
+ rl_point = old_point;
+ if (!whitespace (rl_line_buffer[rl_point]))
+ rl_forward_word (1, 0);
+ }
+}
+
+#if defined (ALIAS)
+/* Expand aliases in the current readline line. */
+static int
+alias_expand_line (count, ignore)
+ int count, ignore;
+{
+ char *new_line;
+
+ new_line = alias_expand (rl_line_buffer);
+
+ if (new_line)
+ {
+ set_up_new_line (new_line);
+ return (0);
+ }
+ else
+ {
+ cleanup_expansion_error ();
+ return (1);
+ }
+}
+#endif
+
+#if defined (BANG_HISTORY)
+/* History expand the line. */
+static int
+history_expand_line (count, ignore)
+ int count, ignore;
+{
+ char *new_line;
+
+ new_line = history_expand_line_internal (rl_line_buffer);
+
+ if (new_line)
+ {
+ set_up_new_line (new_line);
+ return (0);
+ }
+ else
+ {
+ cleanup_expansion_error ();
+ return (1);
+ }
+}
+
+/* Expand history substitutions in the current line and then insert a
+ space (hopefully close to where we were before). */
+static int
+tcsh_magic_space (count, ignore)
+ int count, ignore;
+{
+ int dist_from_end, old_point;
+
+ old_point = rl_point;
+ dist_from_end = rl_end - rl_point;
+ if (history_expand_line (count, ignore) == 0)
+ {
+ /* Try a simple heuristic from Stephen Gildea <gildea@intouchsys.com>.
+ This works if all expansions were before rl_point or if no expansions
+ were performed. */
+ rl_point = (old_point == 0) ? old_point : rl_end - dist_from_end;
+ rl_insert (1, ' ');
+ return (0);
+ }
+ else
+ return (1);
+}
+#endif /* BANG_HISTORY */
+
+/* History and alias expand the line. */
+static int
+history_and_alias_expand_line (count, ignore)
+ int count, ignore;
+{
+ char *new_line;
+
+ new_line = 0;
+#if defined (BANG_HISTORY)
+ new_line = history_expand_line_internal (rl_line_buffer);
+#endif
+
+#if defined (ALIAS)
+ if (new_line)
+ {
+ char *alias_line;
+
+ alias_line = alias_expand (new_line);
+ free (new_line);
+ new_line = alias_line;
+ }
+#endif /* ALIAS */
+
+ if (new_line)
+ {
+ set_up_new_line (new_line);
+ return (0);
+ }
+ else
+ {
+ cleanup_expansion_error ();
+ return (1);
+ }
+}
+
+/* History and alias expand the line, then perform the shell word
+ expansions by calling expand_string. This can't use set_up_new_line()
+ because we want the variable expansions as a separate undo'able
+ set of operations. */
+static int
+shell_expand_line (count, ignore)
+ int count, ignore;
+{
+ char *new_line;
+ WORD_LIST *expanded_string;
+
+ new_line = 0;
+#if defined (BANG_HISTORY)
+ new_line = history_expand_line_internal (rl_line_buffer);
+#endif
+
+#if defined (ALIAS)
+ if (new_line)
+ {
+ char *alias_line;
+
+ alias_line = alias_expand (new_line);
+ free (new_line);
+ new_line = alias_line;
+ }
+#endif /* ALIAS */
+
+ if (new_line)
+ {
+ int old_point = rl_point;
+ int at_end = rl_point == rl_end;
+
+ /* If the line was history and alias expanded, then make that
+ be one thing to undo. */
+ maybe_make_readline_line (new_line);
+ free (new_line);
+
+ /* If there is variable expansion to perform, do that as a separate
+ operation to be undone. */
+ new_line = savestring (rl_line_buffer);
+ expanded_string = expand_string (new_line, 0);
+ FREE (new_line);
+ if (expanded_string == 0)
+ {
+ new_line = (char *)xmalloc (1);
+ new_line[0] = '\0';
+ }
+ else
+ {
+ new_line = string_list (expanded_string);
+ dispose_words (expanded_string);
+ }
+
+ maybe_make_readline_line (new_line);
+ free (new_line);
+
+ /* Place rl_point where we think it should go. */
+ if (at_end)
+ rl_point = rl_end;
+ else if (old_point < rl_end)
+ {
+ rl_point = old_point;
+ if (!whitespace (rl_line_buffer[rl_point]))
+ rl_forward_word (1, 0);
+ }
+ return 0;
+ }
+ else
+ {
+ cleanup_expansion_error ();
+ return 1;
+ }
+}
+
+/* If FIGNORE is set, then don't match files with the given suffixes when
+ completing filenames. If only one of the possibilities has an acceptable
+ suffix, delete the others, else just return and let the completer
+ signal an error. It is called by the completer when real
+ completions are done on filenames by the completer's internal
+ function, not for completion lists (M-?) and not on "other"
+ completion types, such as hostnames or commands. */
+
+static struct ignorevar fignore =
+{
+ "FIGNORE",
+ (struct ign *)0,
+ 0,
+ (char *)0,
+ (sh_iv_item_func_t *) 0,
+};
+
+static void
+_ignore_completion_names (names, name_func)
+ char **names;
+ sh_ignore_func_t *name_func;
+{
+ char **newnames;
+ int idx, nidx;
+ char **oldnames;
+ int oidx;
+
+ /* If there is only one completion, see if it is acceptable. If it is
+ not, free it up. In any case, short-circuit and return. This is a
+ special case because names[0] is not the prefix of the list of names
+ if there is only one completion; it is the completion itself. */
+ if (names[1] == (char *)0)
+ {
+ if (force_fignore)
+ if ((*name_func) (names[0]) == 0)
+ {
+ free (names[0]);
+ names[0] = (char *)NULL;
+ }
+
+ return;
+ }
+
+ /* Allocate space for array to hold list of pointers to matching
+ filenames. The pointers are copied back to NAMES when done. */
+ for (nidx = 1; names[nidx]; nidx++)
+ ;
+ newnames = strvec_create (nidx + 1);
+
+ if (force_fignore == 0)
+ {
+ oldnames = strvec_create (nidx - 1);
+ oidx = 0;
+ }
+
+ newnames[0] = names[0];
+ for (idx = nidx = 1; names[idx]; idx++)
+ {
+ if ((*name_func) (names[idx]))
+ newnames[nidx++] = names[idx];
+ else if (force_fignore == 0)
+ oldnames[oidx++] = names[idx];
+ else
+ free (names[idx]);
+ }
+
+ newnames[nidx] = (char *)NULL;
+
+ /* If none are acceptable then let the completer handle it. */
+ if (nidx == 1)
+ {
+ if (force_fignore)
+ {
+ free (names[0]);
+ names[0] = (char *)NULL;
+ }
+ else
+ free (oldnames);
+
+ free (newnames);
+ return;
+ }
+
+ if (force_fignore == 0)
+ {
+ while (oidx)
+ free (oldnames[--oidx]);
+ free (oldnames);
+ }
+
+ /* If only one is acceptable, copy it to names[0] and return. */
+ if (nidx == 2)
+ {
+ free (names[0]);
+ names[0] = newnames[1];
+ names[1] = (char *)NULL;
+ free (newnames);
+ return;
+ }
+
+ /* Copy the acceptable names back to NAMES, set the new array end,
+ and return. */
+ for (nidx = 1; newnames[nidx]; nidx++)
+ names[nidx] = newnames[nidx];
+ names[nidx] = (char *)NULL;
+ free (newnames);
+}
+
+static int
+name_is_acceptable (name)
+ const char *name;
+{
+ struct ign *p;
+ int nlen;
+
+ for (nlen = strlen (name), p = fignore.ignores; p->val; p++)
+ {
+ if (nlen > p->len && p->len > 0 && STREQ (p->val, &name[nlen - p->len]))
+ return (0);
+ }
+
+ return (1);
+}
+
+#if 0
+static int
+ignore_dot_names (name)
+ char *name;
+{
+ return (name[0] != '.');
+}
+#endif
+
+static int
+filename_completion_ignore (names)
+ char **names;
+{
+#if 0
+ if (glob_dot_filenames == 0)
+ _ignore_completion_names (names, ignore_dot_names);
+#endif
+
+ setup_ignore_patterns (&fignore);
+
+ if (fignore.num_ignores == 0)
+ return 0;
+
+ _ignore_completion_names (names, name_is_acceptable);
+
+ return 0;
+}
+
+/* Return 1 if NAME is a directory. NAME undergoes tilde expansion. */
+static int
+test_for_directory (name)
+ const char *name;
+{
+ char *fn;
+ int r;
+
+ fn = bash_tilde_expand (name, 0);
+ r = file_isdir (fn);
+ free (fn);
+
+ return (r);
+}
+
+/* Remove files from NAMES, leaving directories. */
+static int
+bash_ignore_filenames (names)
+ char **names;
+{
+ _ignore_completion_names (names, test_for_directory);
+ return 0;
+}
+
+static int
+return_zero (name)
+ const char *name;
+{
+ return 0;
+}
+
+static int
+bash_ignore_everything (names)
+ char **names;
+{
+ _ignore_completion_names (names, return_zero);
+ return 0;
+}
+
+/* Replace a tilde-prefix in VAL with a `~', assuming the user typed it. VAL
+ is an expanded filename. DIRECTORY_PART is the tilde-prefix portion
+ of the un-tilde-expanded version of VAL (what the user typed). */
+static char *
+restore_tilde (val, directory_part)
+ char *val, *directory_part;
+{
+ int l, vl, dl2, xl;
+ char *dh2, *expdir, *ret;
+
+ vl = strlen (val);
+
+ /* We need to duplicate the expansions readline performs on the directory
+ portion before passing it to our completion function. */
+ dh2 = directory_part ? bash_dequote_filename (directory_part, 0) : 0;
+ bash_directory_expansion (&dh2);
+ dl2 = strlen (dh2);
+
+ expdir = bash_tilde_expand (directory_part, 0);
+ xl = strlen (expdir);
+ free (expdir);
+
+ /*
+ dh2 = unexpanded but dequoted tilde-prefix
+ dl2 = length of tilde-prefix
+ expdir = tilde-expanded tilde-prefix
+ xl = length of expanded tilde-prefix
+ l = length of remainder after tilde-prefix
+ */
+ l = (vl - xl) + 1;
+
+ ret = (char *)xmalloc (dl2 + 2 + l);
+ strcpy (ret, dh2);
+ strcpy (ret + dl2, val + xl);
+
+ free (dh2);
+ return (ret);
+}
+
+static char *
+maybe_restore_tilde (val, directory_part)
+ char *val, *directory_part;
+{
+ rl_icppfunc_t *save;
+ char *ret;
+
+ save = (dircomplete_expand == 0) ? save_directory_hook () : (rl_icppfunc_t *)0;
+ ret = restore_tilde (val, directory_part);
+ if (save)
+ restore_directory_hook (save);
+ return ret;
+}
+
+/* Simulate the expansions that will be performed by
+ rl_filename_completion_function. This must be called with the address of
+ a pointer to malloc'd memory. */
+static void
+bash_directory_expansion (dirname)
+ char **dirname;
+{
+ char *d, *nd;
+
+ d = savestring (*dirname);
+
+ if ((rl_directory_rewrite_hook) && (*rl_directory_rewrite_hook) (&d))
+ {
+ free (*dirname);
+ *dirname = d;
+ }
+ else if (rl_directory_completion_hook && (*rl_directory_completion_hook) (&d))
+ {
+ free (*dirname);
+ *dirname = d;
+ }
+ else if (rl_completion_found_quote)
+ {
+ nd = bash_dequote_filename (d, rl_completion_quote_character);
+ free (*dirname);
+ free (d);
+ *dirname = nd;
+ }
+}
+
+/* If necessary, rewrite directory entry */
+static char *
+bash_filename_rewrite_hook (fname, fnlen)
+ char *fname;
+ int fnlen;
+{
+ char *conv;
+
+ conv = fnx_fromfs (fname, fnlen);
+ if (conv != fname)
+ conv = savestring (conv);
+ return conv;
+}
+
+/* Functions to save and restore the appropriate directory hook */
+/* This is not static so the shopt code can call it */
+void
+set_directory_hook ()
+{
+ if (dircomplete_expand)
+ {
+ rl_directory_completion_hook = bash_directory_completion_hook;
+ rl_directory_rewrite_hook = (rl_icppfunc_t *)0;
+ }
+ else
+ {
+ rl_directory_rewrite_hook = bash_directory_completion_hook;
+ rl_directory_completion_hook = (rl_icppfunc_t *)0;
+ }
+}
+
+static rl_icppfunc_t *
+save_directory_hook ()
+{
+ rl_icppfunc_t *ret;
+
+ if (dircomplete_expand)
+ {
+ ret = rl_directory_completion_hook;
+ rl_directory_completion_hook = (rl_icppfunc_t *)NULL;
+ }
+ else
+ {
+ ret = rl_directory_rewrite_hook;
+ rl_directory_rewrite_hook = (rl_icppfunc_t *)NULL;
+ }
+
+ return ret;
+}
+
+static void
+restore_directory_hook (hookf)
+ rl_icppfunc_t *hookf;
+{
+ if (dircomplete_expand)
+ rl_directory_completion_hook = hookf;
+ else
+ rl_directory_rewrite_hook = hookf;
+}
+
+/* Expand a filename before the readline completion code passes it to stat(2).
+ The filename will already have had tilde expansion performed. */
+static int
+bash_filename_stat_hook (dirname)
+ char **dirname;
+{
+ char *local_dirname, *new_dirname, *t;
+ int should_expand_dirname, return_value;
+ WORD_LIST *wl;
+ struct stat sb;
+
+ local_dirname = *dirname;
+ should_expand_dirname = return_value = 0;
+ if (t = mbschr (local_dirname, '$'))
+ should_expand_dirname = '$';
+ else if (t = mbschr (local_dirname, '`')) /* XXX */
+ should_expand_dirname = '`';
+
+#if defined (HAVE_LSTAT)
+ if (should_expand_dirname && lstat (local_dirname, &sb) == 0)
+#else
+ if (should_expand_dirname && stat (local_dirname, &sb) == 0)
+#endif
+ should_expand_dirname = 0;
+
+ if (should_expand_dirname)
+ {
+ new_dirname = savestring (local_dirname);
+ wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB); /* does the right thing */
+ if (wl)
+ {
+ free (new_dirname);
+ new_dirname = string_list (wl);
+ /* Tell the completer we actually expanded something and change
+ *dirname only if we expanded to something non-null -- stat
+ behaves unpredictably when passed null or empty strings */
+ if (new_dirname && *new_dirname)
+ {
+ free (local_dirname); /* XXX */
+ local_dirname = *dirname = new_dirname;
+ return_value = STREQ (local_dirname, *dirname) == 0;
+ }
+ else
+ free (new_dirname);
+ dispose_words (wl);
+ }
+ else
+ free (new_dirname);
+ }
+
+ /* This is very similar to the code in bash_directory_completion_hook below,
+ but without spelling correction and not worrying about whether or not
+ we change relative pathnames. */
+ if (no_symbolic_links == 0 && (local_dirname[0] != '.' || local_dirname[1]))
+ {
+ char *temp1, *temp2;
+
+ t = get_working_directory ("symlink-hook");
+ temp1 = make_absolute (local_dirname, t);
+ free (t);
+ temp2 = sh_canonpath (temp1, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);
+
+ /* If we can't canonicalize, bail. */
+ if (temp2 == 0)
+ {
+ free (temp1);
+ return return_value;
+ }
+
+ free (local_dirname);
+ *dirname = temp2;
+ free (temp1);
+ }
+
+ return (return_value);
+}
+
+/* Handle symbolic link references and other directory name
+ expansions while hacking completion. This should return 1 if it modifies
+ the DIRNAME argument, 0 otherwise. It should make sure not to modify
+ DIRNAME if it returns 0. */
+static int
+bash_directory_completion_hook (dirname)
+ char **dirname;
+{
+ char *local_dirname, *new_dirname, *t;
+ int return_value, should_expand_dirname, nextch, closer;
+ WORD_LIST *wl;
+ struct stat sb;
+
+ return_value = should_expand_dirname = nextch = closer = 0;
+ local_dirname = *dirname;
+
+ if (t = mbschr (local_dirname, '$'))
+ {
+ should_expand_dirname = '$';
+ nextch = t[1];
+ /* Deliberately does not handle the deprecated $[...] arithmetic
+ expansion syntax */
+ if (nextch == '(')
+ closer = ')';
+ else if (nextch == '{')
+ closer = '}';
+ else
+ nextch = 0;
+ }
+ else if (local_dirname[0] == '~')
+ should_expand_dirname = '~';
+ else
+ {
+ t = mbschr (local_dirname, '`');
+ if (t && unclosed_pair (local_dirname, strlen (local_dirname), "`") == 0)
+ should_expand_dirname = '`';
+ }
+
+#if defined (HAVE_LSTAT)
+ if (should_expand_dirname && lstat (local_dirname, &sb) == 0)
+#else
+ if (should_expand_dirname && stat (local_dirname, &sb) == 0)
+#endif
+ should_expand_dirname = 0;
+
+ if (should_expand_dirname)
+ {
+ new_dirname = savestring (local_dirname);
+ wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB); /* does the right thing */
+ if (wl)
+ {
+ *dirname = string_list (wl);
+ /* Tell the completer to replace the directory name only if we
+ actually expanded something. */
+ return_value = STREQ (local_dirname, *dirname) == 0;
+ free (local_dirname);
+ free (new_dirname);
+ dispose_words (wl);
+ local_dirname = *dirname;
+ /* XXX - change rl_filename_quote_characters here based on
+ should_expand_dirname/nextch/closer. This is the only place
+ custom_filename_quote_characters is modified. */
+ if (rl_filename_quote_characters && *rl_filename_quote_characters)
+ {
+ int i, j, c;
+ i = strlen (default_filename_quote_characters);
+ custom_filename_quote_characters = xrealloc (custom_filename_quote_characters, i+1);
+ for (i = j = 0; c = default_filename_quote_characters[i]; i++)
+ {
+ if (c == should_expand_dirname || c == nextch || c == closer)
+ continue;
+ custom_filename_quote_characters[j++] = c;
+ }
+ custom_filename_quote_characters[j] = '\0';
+ rl_filename_quote_characters = custom_filename_quote_characters;
+ set_filename_bstab (rl_filename_quote_characters);
+ }
+ }
+ else
+ {
+ free (new_dirname);
+ free (local_dirname);
+ *dirname = (char *)xmalloc (1);
+ **dirname = '\0';
+ return 1;
+ }
+ }
+ else
+ {
+ /* Dequote the filename even if we don't expand it. */
+ new_dirname = bash_dequote_filename (local_dirname, rl_completion_quote_character);
+ return_value = STREQ (local_dirname, new_dirname) == 0;
+ free (local_dirname);
+ local_dirname = *dirname = new_dirname;
+ }
+
+ /* no_symbolic_links == 0 -> use (default) logical view of the file system.
+ local_dirname[0] == '.' && local_dirname[1] == '/' means files in the
+ current directory (./).
+ local_dirname[0] == '.' && local_dirname[1] == 0 means relative pathnames
+ in the current directory (e.g., lib/sh).
+ XXX - should we do spelling correction on these? */
+
+ /* This is test as it was in bash-4.2: skip relative pathnames in current
+ directory. Change test to
+ (local_dirname[0] != '.' || (local_dirname[1] && local_dirname[1] != '/'))
+ if we want to skip paths beginning with ./ also. */
+ if (no_symbolic_links == 0 && (local_dirname[0] != '.' || local_dirname[1]))
+ {
+ char *temp1, *temp2;
+ int len1, len2;
+
+ /* If we have a relative path
+ (local_dirname[0] != '/' && local_dirname[0] != '.')
+ that is canonical after appending it to the current directory, then
+ temp1 = temp2+'/'
+ That is,
+ strcmp (temp1, temp2) == 0
+ after adding a slash to temp2 below. It should be safe to not
+ change those.
+ */
+ t = get_working_directory ("symlink-hook");
+ temp1 = make_absolute (local_dirname, t);
+ free (t);
+ temp2 = sh_canonpath (temp1, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);
+
+ /* Try spelling correction if initial canonicalization fails. Make
+ sure we are set to replace the directory name with the results so
+ subsequent directory checks don't fail. */
+ if (temp2 == 0 && dircomplete_spelling && dircomplete_expand)
+ {
+ temp2 = dirspell (temp1);
+ if (temp2)
+ {
+ free (temp1);
+ temp1 = temp2;
+ temp2 = sh_canonpath (temp1, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);
+ return_value |= temp2 != 0;
+ }
+ }
+ /* If we can't canonicalize, bail. */
+ if (temp2 == 0)
+ {
+ free (temp1);
+ return return_value;
+ }
+ len1 = strlen (temp1);
+ if (temp1[len1 - 1] == '/')
+ {
+ len2 = strlen (temp2);
+ if (len2 > 2) /* don't append `/' to `/' or `//' */
+ {
+ temp2 = (char *)xrealloc (temp2, len2 + 2);
+ temp2[len2] = '/';
+ temp2[len2 + 1] = '\0';
+ }
+ }
+
+ /* dircomplete_expand_relpath == 0 means we want to leave relative
+ pathnames that are unchanged by canonicalization alone.
+ *local_dirname != '/' && *local_dirname != '.' == relative pathname
+ (consistent with general.c:absolute_pathname())
+ temp1 == temp2 (after appending a slash to temp2) means the pathname
+ is not changed by canonicalization as described above. */
+ if (dircomplete_expand_relpath || ((local_dirname[0] != '/' && local_dirname[0] != '.') && STREQ (temp1, temp2) == 0))
+ return_value |= STREQ (local_dirname, temp2) == 0;
+ free (local_dirname);
+ *dirname = temp2;
+ free (temp1);
+ }
+
+ return (return_value);
+}
+
+static char **history_completion_array = (char **)NULL;
+static int harry_size;
+static int harry_len;
+
+static void
+build_history_completion_array ()
+{
+ register int i, j;
+ HIST_ENTRY **hlist;
+ char **tokens;
+
+ /* First, clear out the current dynamic history completion list. */
+ if (harry_size)
+ {
+ strvec_dispose (history_completion_array);
+ history_completion_array = (char **)NULL;
+ harry_size = 0;
+ harry_len = 0;
+ }
+
+ /* Next, grovel each line of history, making each shell-sized token
+ a separate entry in the history_completion_array. */
+ hlist = history_list ();
+
+ if (hlist)
+ {
+ for (i = 0; hlist[i]; i++)
+ ;
+ for ( --i; i >= 0; i--)
+ {
+ /* Separate each token, and place into an array. */
+ tokens = history_tokenize (hlist[i]->line);
+
+ for (j = 0; tokens && tokens[j]; j++)
+ {
+ if (harry_len + 2 > harry_size)
+ history_completion_array = strvec_resize (history_completion_array, harry_size += 10);
+
+ history_completion_array[harry_len++] = tokens[j];
+ history_completion_array[harry_len] = (char *)NULL;
+ }
+ free (tokens);
+ }
+
+ /* Sort the complete list of tokens. */
+ if (dabbrev_expand_active == 0)
+ qsort (history_completion_array, harry_len, sizeof (char *), (QSFUNC *)strvec_strcmp);
+ }
+}
+
+static char *
+history_completion_generator (hint_text, state)
+ const char *hint_text;
+ int state;
+{
+ static int local_index, len;
+ static const char *text;
+
+ /* If this is the first call to the generator, then initialize the
+ list of strings to complete over. */
+ if (state == 0)
+ {
+ if (dabbrev_expand_active) /* This is kind of messy */
+ rl_completion_suppress_append = 1;
+ local_index = 0;
+ build_history_completion_array ();
+ text = hint_text;
+ len = strlen (text);
+ }
+
+ while (history_completion_array && history_completion_array[local_index])
+ {
+ if (strncmp (text, history_completion_array[local_index++], len) == 0)
+ return (savestring (history_completion_array[local_index - 1]));
+ }
+ return ((char *)NULL);
+}
+
+static int
+dynamic_complete_history (count, key)
+ int count, key;
+{
+ int r;
+ rl_compentry_func_t *orig_func;
+ rl_completion_func_t *orig_attempt_func;
+ rl_compignore_func_t *orig_ignore_func;
+
+ orig_func = rl_completion_entry_function;
+ orig_attempt_func = rl_attempted_completion_function;
+ orig_ignore_func = rl_ignore_some_completions_function;
+
+ rl_completion_entry_function = history_completion_generator;
+ rl_attempted_completion_function = (rl_completion_func_t *)NULL;
+ rl_ignore_some_completions_function = filename_completion_ignore;
+
+ /* XXX - use rl_completion_mode here? */
+ if (rl_last_func == dynamic_complete_history)
+ r = rl_complete_internal ('?');
+ else
+ r = rl_complete_internal (TAB);
+
+ rl_completion_entry_function = orig_func;
+ rl_attempted_completion_function = orig_attempt_func;
+ rl_ignore_some_completions_function = orig_ignore_func;
+
+ return r;
+}
+
+static int
+bash_dabbrev_expand (count, key)
+ int count, key;
+{
+ int r, orig_suppress, orig_sort;
+ rl_compentry_func_t *orig_func;
+ rl_completion_func_t *orig_attempt_func;
+ rl_compignore_func_t *orig_ignore_func;
+
+ orig_func = rl_menu_completion_entry_function;
+ orig_attempt_func = rl_attempted_completion_function;
+ orig_ignore_func = rl_ignore_some_completions_function;
+ orig_suppress = rl_completion_suppress_append;
+ orig_sort = rl_sort_completion_matches;
+
+ rl_menu_completion_entry_function = history_completion_generator;
+ rl_attempted_completion_function = (rl_completion_func_t *)NULL;
+ rl_ignore_some_completions_function = filename_completion_ignore;
+ rl_filename_completion_desired = 0;
+ rl_completion_suppress_append = 1;
+ rl_sort_completion_matches = 0;
+
+ /* XXX - use rl_completion_mode here? */
+ dabbrev_expand_active = 1;
+ if (rl_last_func == bash_dabbrev_expand)
+ rl_last_func = rl_menu_complete;
+ r = rl_menu_complete (count, key);
+ dabbrev_expand_active = 0;
+
+ rl_last_func = bash_dabbrev_expand;
+ rl_menu_completion_entry_function = orig_func;
+ rl_attempted_completion_function = orig_attempt_func;
+ rl_ignore_some_completions_function = orig_ignore_func;
+ rl_completion_suppress_append = orig_suppress;
+ rl_sort_completion_matches = orig_sort;
+
+ return r;
+}
+
+#if defined (SPECIFIC_COMPLETION_FUNCTIONS)
+static int
+bash_complete_username (ignore, ignore2)
+ int ignore, ignore2;
+{
+ return bash_complete_username_internal (rl_completion_mode (bash_complete_username));
+}
+
+static int
+bash_possible_username_completions (ignore, ignore2)
+ int ignore, ignore2;
+{
+ return bash_complete_username_internal ('?');
+}
+
+static int
+bash_complete_username_internal (what_to_do)
+ int what_to_do;
+{
+ return bash_specific_completion (what_to_do, rl_username_completion_function);
+}
+
+static int
+bash_complete_filename (ignore, ignore2)
+ int ignore, ignore2;
+{
+ return bash_complete_filename_internal (rl_completion_mode (bash_complete_filename));
+}
+
+static int
+bash_possible_filename_completions (ignore, ignore2)
+ int ignore, ignore2;
+{
+ return bash_complete_filename_internal ('?');
+}
+
+static int
+bash_complete_filename_internal (what_to_do)
+ int what_to_do;
+{
+ rl_compentry_func_t *orig_func;
+ rl_completion_func_t *orig_attempt_func;
+ rl_icppfunc_t *orig_dir_func;
+ rl_compignore_func_t *orig_ignore_func;
+ /*const*/ char *orig_rl_completer_word_break_characters;
+ int r;
+
+ orig_func = rl_completion_entry_function;
+ orig_attempt_func = rl_attempted_completion_function;
+ orig_ignore_func = rl_ignore_some_completions_function;
+ orig_rl_completer_word_break_characters = rl_completer_word_break_characters;
+
+ orig_dir_func = save_directory_hook ();
+
+ rl_completion_entry_function = rl_filename_completion_function;
+ rl_attempted_completion_function = (rl_completion_func_t *)NULL;
+ rl_ignore_some_completions_function = filename_completion_ignore;
+ rl_completer_word_break_characters = " \t\n\"\'";
+
+ r = rl_complete_internal (what_to_do);
+
+ rl_completion_entry_function = orig_func;
+ rl_attempted_completion_function = orig_attempt_func;
+ rl_ignore_some_completions_function = orig_ignore_func;
+ rl_completer_word_break_characters = orig_rl_completer_word_break_characters;
+
+ restore_directory_hook (orig_dir_func);
+
+ return r;
+}
+
+static int
+bash_complete_hostname (ignore, ignore2)
+ int ignore, ignore2;
+{
+ return bash_complete_hostname_internal (rl_completion_mode (bash_complete_hostname));
+}
+
+static int
+bash_possible_hostname_completions (ignore, ignore2)
+ int ignore, ignore2;
+{
+ return bash_complete_hostname_internal ('?');
+}
+
+static int
+bash_complete_variable (ignore, ignore2)
+ int ignore, ignore2;
+{
+ return bash_complete_variable_internal (rl_completion_mode (bash_complete_variable));
+}
+
+static int
+bash_possible_variable_completions (ignore, ignore2)
+ int ignore, ignore2;
+{
+ return bash_complete_variable_internal ('?');
+}
+
+static int
+bash_complete_command (ignore, ignore2)
+ int ignore, ignore2;
+{
+ return bash_complete_command_internal (rl_completion_mode (bash_complete_command));
+}
+
+static int
+bash_possible_command_completions (ignore, ignore2)
+ int ignore, ignore2;
+{
+ return bash_complete_command_internal ('?');
+}
+
+static int
+bash_complete_hostname_internal (what_to_do)
+ int what_to_do;
+{
+ return bash_specific_completion (what_to_do, hostname_completion_function);
+}
+
+static int
+bash_complete_variable_internal (what_to_do)
+ int what_to_do;
+{
+ return bash_specific_completion (what_to_do, variable_completion_function);
+}
+
+static int
+bash_complete_command_internal (what_to_do)
+ int what_to_do;
+{
+ return bash_specific_completion (what_to_do, command_word_completion_function);
+}
+
+static char *globtext;
+static char *globorig;
+
+static char *
+glob_complete_word (text, state)
+ const char *text;
+ int state;
+{
+ static char **matches = (char **)NULL;
+ static int ind;
+ int glen;
+ char *ret, *ttext;
+
+ if (state == 0)
+ {
+ rl_filename_completion_desired = 1;
+ FREE (matches);
+ if (globorig != globtext)
+ FREE (globorig);
+ FREE (globtext);
+
+ ttext = bash_tilde_expand (text, 0);
+
+ if (rl_explicit_arg)
+ {
+ globorig = savestring (ttext);
+ glen = strlen (ttext);
+ globtext = (char *)xmalloc (glen + 2);
+ strcpy (globtext, ttext);
+ globtext[glen] = '*';
+ globtext[glen+1] = '\0';
+ }
+ else
+ globtext = globorig = savestring (ttext);
+
+ if (ttext != text)
+ free (ttext);
+
+ matches = shell_glob_filename (globtext);
+ if (GLOB_FAILED (matches))
+ matches = (char **)NULL;
+ ind = 0;
+ }
+
+ ret = matches ? matches[ind] : (char *)NULL;
+ ind++;
+ return ret;
+}
+
+static int
+bash_glob_completion_internal (what_to_do)
+ int what_to_do;
+{
+ return bash_specific_completion (what_to_do, glob_complete_word);
+}
+
+/* A special quoting function so we don't end up quoting globbing characters
+ in the word if there are no matches or multiple matches. */
+static char *
+bash_glob_quote_filename (s, rtype, qcp)
+ char *s;
+ int rtype;
+ char *qcp;
+{
+ if (globorig && qcp && *qcp == '\0' && STREQ (s, globorig))
+ return (savestring (s));
+ else
+ return (bash_quote_filename (s, rtype, qcp));
+}
+
+static int
+bash_glob_complete_word (count, key)
+ int count, key;
+{
+ int r;
+ rl_quote_func_t *orig_quoting_function;
+
+ if (rl_editing_mode == EMACS_EDITING_MODE)
+ rl_explicit_arg = 1; /* force `*' append */
+ orig_quoting_function = rl_filename_quoting_function;
+ rl_filename_quoting_function = bash_glob_quote_filename;
+
+ r = bash_glob_completion_internal (rl_completion_mode (bash_glob_complete_word));
+
+ rl_filename_quoting_function = orig_quoting_function;
+ return r;
+}
+
+static int
+bash_glob_expand_word (count, key)
+ int count, key;
+{
+ return bash_glob_completion_internal ('*');
+}
+
+static int
+bash_glob_list_expansions (count, key)
+ int count, key;
+{
+ return bash_glob_completion_internal ('?');
+}
+
+static int
+bash_specific_completion (what_to_do, generator)
+ int what_to_do;
+ rl_compentry_func_t *generator;
+{
+ rl_compentry_func_t *orig_func;
+ rl_completion_func_t *orig_attempt_func;
+ rl_compignore_func_t *orig_ignore_func;
+ int r;
+
+ orig_func = rl_completion_entry_function;
+ orig_attempt_func = rl_attempted_completion_function;
+ orig_ignore_func = rl_ignore_some_completions_function;
+ rl_completion_entry_function = generator;
+ rl_attempted_completion_function = NULL;
+ rl_ignore_some_completions_function = orig_ignore_func;
+
+ r = rl_complete_internal (what_to_do);
+
+ rl_completion_entry_function = orig_func;
+ rl_attempted_completion_function = orig_attempt_func;
+ rl_ignore_some_completions_function = orig_ignore_func;
+
+ return r;
+}
+
+#endif /* SPECIFIC_COMPLETION_FUNCTIONS */
+
+#if defined (VI_MODE)
+/* Completion, from vi mode's point of view. This is a modified version of
+ rl_vi_complete which uses the bash globbing code to implement what POSIX
+ specifies, which is to append a `*' and attempt filename generation (which
+ has the side effect of expanding any globbing characters in the word). */
+static int
+bash_vi_complete (count, key)
+ int count, key;
+{
+#if defined (SPECIFIC_COMPLETION_FUNCTIONS)
+ int p, r;
+ char *t;
+
+ if ((rl_point < rl_end) && (!whitespace (rl_line_buffer[rl_point])))
+ {
+ if (!whitespace (rl_line_buffer[rl_point + 1]))
+ rl_vi_end_word (1, 'E');
+ rl_point++;
+ }
+
+ /* Find boundaries of current word, according to vi definition of a
+ `bigword'. */
+ t = 0;
+ if (rl_point > 0)
+ {
+ p = rl_point;
+ rl_vi_bWord (1, 'B');
+ r = rl_point;
+ rl_point = p;
+ p = r;
+
+ t = substring (rl_line_buffer, p, rl_point);
+ }
+
+ if (t && glob_pattern_p (t) == 0)
+ rl_explicit_arg = 1; /* XXX - force glob_complete_word to append `*' */
+ FREE (t);
+
+ if (key == '*') /* Expansion and replacement. */
+ r = bash_glob_expand_word (count, key);
+ else if (key == '=') /* List possible completions. */
+ r = bash_glob_list_expansions (count, key);
+ else if (key == '\\') /* Standard completion */
+ r = bash_glob_complete_word (count, key);
+ else
+ r = rl_complete (0, key);
+
+ if (key == '*' || key == '\\')
+ rl_vi_start_inserting (key, 1, 1);
+
+ return (r);
+#else
+ return rl_vi_complete (count, key);
+#endif /* !SPECIFIC_COMPLETION_FUNCTIONS */
+}
+#endif /* VI_MODE */
+
+/* Filename quoting for completion. */
+/* A function to strip unquoted quote characters (single quotes, double
+ quotes, and backslashes). It allows single quotes to appear
+ within double quotes, and vice versa. It should be smarter. */
+static char *
+bash_dequote_filename (text, quote_char)
+ char *text;
+ int quote_char;
+{
+ char *ret, *p, *r;
+ int l, quoted;
+
+ l = strlen (text);
+ ret = (char *)xmalloc (l + 1);
+ for (quoted = quote_char, p = text, r = ret; p && *p; p++)
+ {
+ /* Allow backslash-escaped characters to pass through unscathed. */
+ if (*p == '\\')
+ {
+ /* Backslashes are preserved within single quotes. */
+ if (quoted == '\'')
+ *r++ = *p;
+ /* Backslashes are preserved within double quotes unless the
+ character is one that is defined to be escaped */
+ else if (quoted == '"' && ((sh_syntaxtab[p[1]] & CBSDQUOTE) == 0))
+ *r++ = *p;
+
+ *r++ = *++p;
+ if (*p == '\0')
+ return ret; /* XXX - was break; */
+ continue;
+ }
+ /* Close quote. */
+ if (quoted && *p == quoted)
+ {
+ quoted = 0;
+ continue;
+ }
+ /* Open quote. */
+ if (quoted == 0 && (*p == '\'' || *p == '"'))
+ {
+ quoted = *p;
+ continue;
+ }
+ *r++ = *p;
+ }
+ *r = '\0';
+ return ret;
+}
+
+/* Quote characters that the readline completion code would treat as
+ word break characters with backslashes. Pass backslash-quoted
+ characters through without examination. */
+static char *
+quote_word_break_chars (text)
+ char *text;
+{
+ char *ret, *r, *s;
+ int l;
+
+ l = strlen (text);
+ ret = (char *)xmalloc ((2 * l) + 1);
+ for (s = text, r = ret; *s; s++)
+ {
+ /* Pass backslash-quoted characters through, including the backslash. */
+ if (*s == '\\')
+ {
+ *r++ = '\\';
+ *r++ = *++s;
+ if (*s == '\0')
+ break;
+ continue;
+ }
+ /* OK, we have an unquoted character. Check its presence in
+ rl_completer_word_break_characters. */
+ if (mbschr (rl_completer_word_break_characters, *s))
+ *r++ = '\\';
+ /* XXX -- check for standalone tildes here and backslash-quote them */
+ if (s == text && *s == '~' && file_exists (text))
+ *r++ = '\\';
+ *r++ = *s;
+ }
+ *r = '\0';
+ return ret;
+}
+
+/* Use characters in STRING to populate the table of characters that should
+ be backslash-quoted. The table will be used for sh_backslash_quote from
+ this file. */
+static void
+set_filename_bstab (string)
+ const char *string;
+{
+ const char *s;
+
+ memset (filename_bstab, 0, sizeof (filename_bstab));
+ for (s = string; s && *s; s++)
+ filename_bstab[*s] = 1;
+}
+
+/* Quote a filename using double quotes, single quotes, or backslashes
+ depending on the value of completion_quoting_style. If we're
+ completing using backslashes, we need to quote some additional
+ characters (those that readline treats as word breaks), so we call
+ quote_word_break_chars on the result. This returns newly-allocated
+ memory. */
+static char *
+bash_quote_filename (s, rtype, qcp)
+ char *s;
+ int rtype;
+ char *qcp;
+{
+ char *rtext, *mtext, *ret;
+ int rlen, cs;
+
+ rtext = (char *)NULL;
+
+ /* If RTYPE == MULT_MATCH, it means that there is
+ more than one match. In this case, we do not add
+ the closing quote or attempt to perform tilde
+ expansion. If RTYPE == SINGLE_MATCH, we try
+ to perform tilde expansion, because single and double
+ quotes inhibit tilde expansion by the shell. */
+
+ cs = completion_quoting_style;
+ /* Might need to modify the default completion style based on *qcp,
+ since it's set to any user-provided opening quote. We also change
+ to single-quoting if there is no user-provided opening quote and
+ the word being completed contains newlines, since those are not
+ quoted correctly using backslashes (a backslash-newline pair is
+ special to the shell parser). */
+ if (*qcp == '\0' && cs == COMPLETE_BSQUOTE && mbschr (s, '\n'))
+ cs = COMPLETE_SQUOTE;
+ else if (*qcp == '"')
+ cs = COMPLETE_DQUOTE;
+ else if (*qcp == '\'')
+ cs = COMPLETE_SQUOTE;
+#if defined (BANG_HISTORY)
+ else if (*qcp == '\0' && history_expansion && cs == COMPLETE_DQUOTE &&
+ history_expansion_inhibited == 0 && mbschr (s, '!'))
+ cs = COMPLETE_BSQUOTE;
+
+ if (*qcp == '"' && history_expansion && cs == COMPLETE_DQUOTE &&
+ history_expansion_inhibited == 0 && mbschr (s, '!'))
+ {
+ cs = COMPLETE_BSQUOTE;
+ *qcp = '\0';
+ }
+#endif
+
+ /* Don't tilde-expand backslash-quoted filenames, since only single and
+ double quotes inhibit tilde expansion. */
+ mtext = s;
+ if (mtext[0] == '~' && rtype == SINGLE_MATCH && cs != COMPLETE_BSQUOTE)
+ mtext = bash_tilde_expand (s, 0);
+
+ switch (cs)
+ {
+ case COMPLETE_DQUOTE:
+ rtext = sh_double_quote (mtext);
+ break;
+ case COMPLETE_SQUOTE:
+ rtext = sh_single_quote (mtext);
+ break;
+ case COMPLETE_BSQUOTE:
+ rtext = sh_backslash_quote (mtext, complete_fullquote ? 0 : filename_bstab, 0);
+ break;
+ }
+
+ if (mtext != s)
+ free (mtext);
+
+ /* We may need to quote additional characters: those that readline treats
+ as word breaks that are not quoted by backslash_quote. */
+ if (rtext && cs == COMPLETE_BSQUOTE)
+ {
+ mtext = quote_word_break_chars (rtext);
+ free (rtext);
+ rtext = mtext;
+ }
+
+ /* Leave the opening quote intact. The readline completion code takes
+ care of avoiding doubled opening quotes. */
+ if (rtext)
+ {
+ rlen = strlen (rtext);
+ ret = (char *)xmalloc (rlen + 1);
+ strcpy (ret, rtext);
+ }
+ else
+ {
+ ret = (char *)xmalloc (rlen = 1);
+ ret[0] = '\0';
+ }
+
+ /* If there are multiple matches, cut off the closing quote. */
+ if (rtype == MULT_MATCH && cs != COMPLETE_BSQUOTE)
+ ret[rlen - 1] = '\0';
+ free (rtext);
+ return ret;
+}
+
+/* Support for binding readline key sequences to Unix commands. */
+static Keymap cmd_xmap;
+
+#ifdef _MINIX
+static void
+#else
+static int
+#endif
+putx(c)
+ int c;
+{
+ int x;
+ x = putc (c, rl_outstream);
+#ifndef _MINIX
+ return x;
+#endif
+}
+
+static int
+bash_execute_unix_command (count, key)
+ int count; /* ignored */
+ int key;
+{
+ Keymap ckmap; /* current keymap */
+ Keymap xkmap; /* unix command executing keymap */
+ rl_command_func_t *func;
+ int type;
+ register int i, r;
+ intmax_t mi;
+ sh_parser_state_t ps;
+ char *cmd, *value, *l, *l1, *ce;
+ SHELL_VAR *v;
+ char ibuf[INT_STRLEN_BOUND(int) + 1];
+
+ /* First, we need to find the right command to execute. This is tricky,
+ because we might have already indirected into another keymap, so we
+ have to walk cmd_xmap using the entire key sequence. */
+ cmd = (char *)rl_function_of_keyseq (rl_executing_keyseq, cmd_xmap, &type);
+
+ if (cmd == 0 || type != ISMACR)
+ {
+ rl_crlf ();
+ internal_error (_("bash_execute_unix_command: cannot find keymap for command"));
+ rl_forced_update_display ();
+ return 1;
+ }
+
+ ce = rl_get_termcap ("ce");
+ if (ce) /* clear current line */
+ {
+ fprintf (rl_outstream, "\r");
+ tputs (ce, 1, putx);
+ fflush (rl_outstream);
+ }
+ else
+ rl_crlf (); /* move to a new line */
+
+ v = bind_variable ("READLINE_LINE", rl_line_buffer, 0);
+ if (v)
+ VSETATTR (v, att_exported);
+ l = v ? value_cell (v) : 0;
+ value = inttostr (rl_point, ibuf, sizeof (ibuf));
+ v = bind_int_variable ("READLINE_POINT", value);
+ if (v)
+ VSETATTR (v, att_exported);
+ array_needs_making = 1;
+
+ save_parser_state (&ps);
+ r = parse_and_execute (cmd, "bash_execute_unix_command", SEVAL_NOHIST|SEVAL_NOFREE);
+ restore_parser_state (&ps);
+
+ v = find_variable ("READLINE_LINE");
+ l1 = v ? value_cell (v) : 0;
+ if (l1 != l)
+ maybe_make_readline_line (value_cell (v));
+ v = find_variable ("READLINE_POINT");
+ if (v && legal_number (value_cell (v), &mi))
+ {
+ i = mi;
+ if (i != rl_point)
+ {
+ rl_point = i;
+ if (rl_point > rl_end)
+ rl_point = rl_end;
+ else if (rl_point < 0)
+ rl_point = 0;
+ }
+ }
+
+ unbind_variable ("READLINE_LINE");
+ unbind_variable ("READLINE_POINT");
+ array_needs_making = 1;
+
+ /* and restore the readline buffer and display after command execution. */
+ rl_forced_update_display ();
+ return 0;
+}
+
+int
+print_unix_command_map ()
+{
+ Keymap save;
+
+ save = rl_get_keymap ();
+ rl_set_keymap (cmd_xmap);
+ rl_macro_dumper (1);
+ rl_set_keymap (save);
+ return 0;
+}
+
+static void
+init_unix_command_map ()
+{
+ cmd_xmap = rl_make_bare_keymap ();
+}
+
+static int
+isolate_sequence (string, ind, need_dquote, startp)
+ char *string;
+ int ind, need_dquote, *startp;
+{
+ register int i;
+ int c, passc, delim;
+
+ for (i = ind; string[i] && whitespace (string[i]); i++)
+ ;
+ /* NEED_DQUOTE means that the first non-white character *must* be `"'. */
+ if (need_dquote && string[i] != '"')
+ {
+ builtin_error (_("%s: first non-whitespace character is not `\"'"), string);
+ return -1;
+ }
+
+ /* We can have delimited strings even if NEED_DQUOTE == 0, like the command
+ string to bind the key sequence to. */
+ delim = (string[i] == '"' || string[i] == '\'') ? string[i] : 0;
+
+ if (startp)
+ *startp = delim ? ++i : i;
+
+ for (passc = 0; c = string[i]; i++)
+ {
+ if (passc)
+ {
+ passc = 0;
+ continue;
+ }
+ if (c == '\\')
+ {
+ passc++;
+ continue;
+ }
+ if (c == delim)
+ break;
+ }
+
+ if (delim && string[i] != delim)
+ {
+ builtin_error (_("no closing `%c' in %s"), delim, string);
+ return -1;
+ }
+
+ return i;
+}
+
+int
+bind_keyseq_to_unix_command (line)
+ char *line;
+{
+ Keymap kmap;
+ char *kseq, *value;
+ int i, kstart;
+
+ if (cmd_xmap == 0)
+ init_unix_command_map ();
+
+ kmap = rl_get_keymap ();
+
+ /* We duplicate some of the work done by rl_parse_and_bind here, but
+ this code only has to handle `"keyseq": ["]command["]' and can
+ generate an error for anything else. */
+ i = isolate_sequence (line, 0, 1, &kstart);
+ if (i < 0)
+ return -1;
+
+ /* Create the key sequence string to pass to rl_generic_bind */
+ kseq = substring (line, kstart, i);
+
+ for ( ; line[i] && line[i] != ':'; i++)
+ ;
+ if (line[i] != ':')
+ {
+ builtin_error (_("%s: missing colon separator"), line);
+ FREE (kseq);
+ return -1;
+ }
+
+ i = isolate_sequence (line, i + 1, 0, &kstart);
+ if (i < 0)
+ {
+ FREE (kseq);
+ return -1;
+ }
+
+ /* Create the value string containing the command to execute. */
+ value = substring (line, kstart, i);
+
+ /* Save the command to execute and the key sequence in the CMD_XMAP */
+ rl_generic_bind (ISMACR, kseq, value, cmd_xmap);
+
+ /* and bind the key sequence in the current keymap to a function that
+ understands how to execute from CMD_XMAP */
+ rl_bind_keyseq_in_map (kseq, bash_execute_unix_command, kmap);
+
+ free (kseq);
+ return 0;
+}
+
+/* Used by the programmable completion code. Complete TEXT as a filename,
+ but return only directories as matches. Dequotes the filename before
+ attempting to find matches. */
+char **
+bash_directory_completion_matches (text)
+ const char *text;
+{
+ char **m1;
+ char *dfn;
+ int qc;
+
+ qc = rl_dispatching ? rl_completion_quote_character : 0;
+ /* If rl_completion_found_quote != 0, rl_completion_matches will call the
+ filename dequoting function, causing the directory name to be dequoted
+ twice. */
+ if (rl_dispatching && rl_completion_found_quote == 0)
+ dfn = bash_dequote_filename ((char *)text, qc);
+ else
+ dfn = (char *)text;
+ m1 = rl_completion_matches (dfn, rl_filename_completion_function);
+ if (dfn != text)
+ free (dfn);
+
+ if (m1 == 0 || m1[0] == 0)
+ return m1;
+ /* We don't bother recomputing the lcd of the matches, because it will just
+ get thrown away by the programmable completion code and recomputed
+ later. */
+ (void)bash_ignore_filenames (m1);
+ return m1;
+}
+
+char *
+bash_dequote_text (text)
+ const char *text;
+{
+ char *dtxt;
+ int qc;
+
+ qc = (text[0] == '"' || text[0] == '\'') ? text[0] : 0;
+ dtxt = bash_dequote_filename ((char *)text, qc);
+ return (dtxt);
+}
+
+/* This event hook is designed to be called after readline receives a signal
+ that interrupts read(2). It gives reasonable responsiveness to interrupts
+ and fatal signals without executing too much code in a signal handler
+ context. */
+static int
+bash_event_hook ()
+{
+ /* If we're going to longjmp to top_level, make sure we clean up readline.
+ check_signals will call QUIT, which will eventually longjmp to top_level,
+ calling run_interrupt_trap along the way. The check for sigalrm_seen is
+ to clean up the read builtin's state. */
+ if (interrupt_state || sigalrm_seen)
+ rl_cleanup_after_signal ();
+itrace("bash_event_hook");
+ bashline_reset_event_hook ();
+ check_signals_and_traps (); /* XXX */
+ return 0;
+}
+
+#endif /* READLINE */
{ "compat32", &shopt_compat32, set_compatibility_level },
{ "compat40", &shopt_compat40, set_compatibility_level },
{ "compat41", &shopt_compat41, set_compatibility_level },
- { "compat42", &shopt_compat41, set_compatibility_level },
+ { "compat42", &shopt_compat42, set_compatibility_level },
#if defined (READLINE)
{ "complete_fullquote", &complete_fullquote, (shopt_set_func_t *)NULL},
{ "direxpand", &dircomplete_expand, shopt_set_complete_direxpand },
--- /dev/null
+This file is shopt.def, from which is created shopt.c.
+It implements the Bash `shopt' builtin.
+
+Copyright (C) 1994-2012 Free Software Foundation, Inc.
+
+This file is part of GNU Bash, the Bourne Again SHell.
+
+Bash is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+Bash is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Bash. If not, see <http://www.gnu.org/licenses/>.
+
+$PRODUCES shopt.c
+
+$BUILTIN shopt
+$FUNCTION shopt_builtin
+$SHORT_DOC shopt [-pqsu] [-o] [optname ...]
+Set and unset shell options.
+
+Change the setting of each shell option OPTNAME. Without any option
+arguments, list all shell options with an indication of whether or not each
+is set.
+
+Options:
+ -o restrict OPTNAMEs to those defined for use with `set -o'
+ -p print each shell option with an indication of its status
+ -q suppress output
+ -s enable (set) each OPTNAME
+ -u disable (unset) each OPTNAME
+
+Exit Status:
+Returns success if OPTNAME is enabled; fails if an invalid option is
+given or OPTNAME is disabled.
+$END
+
+#include <config.h>
+
+#if defined (HAVE_UNISTD_H)
+# ifdef _MINIX
+# include <sys/types.h>
+# endif
+# include <unistd.h>
+#endif
+
+#include <stdio.h>
+
+#include "version.h"
+
+#include "../bashintl.h"
+
+#include "../shell.h"
+#include "../flags.h"
+#include "common.h"
+#include "bashgetopt.h"
+
+#if defined (READLINE)
+# include "../bashline.h"
+#endif
+
+#if defined (HISTORY)
+# include "../bashhist.h"
+#endif
+
+#define UNSETOPT 0
+#define SETOPT 1
+
+#define OPTFMT "%-15s\t%s\n"
+
+extern int allow_null_glob_expansion, fail_glob_expansion, glob_dot_filenames;
+extern int cdable_vars, mail_warning, source_uses_path;
+extern int no_exit_on_failed_exec, print_shift_error;
+extern int check_hashed_filenames, promptvars;
+extern int cdspelling, expand_aliases;
+extern int extended_quote;
+extern int check_window_size;
+extern int glob_ignore_case, match_ignore_case;
+extern int hup_on_exit;
+extern int xpg_echo;
+extern int gnu_error_format;
+extern int check_jobs_at_exit;
+extern int autocd;
+extern int glob_star;
+extern int glob_asciirange;
+extern int lastpipe_opt;
+
+#if defined (EXTENDED_GLOB)
+extern int extended_glob;
+#endif
+
+#if defined (READLINE)
+extern int hist_verify, history_reediting, perform_hostname_completion;
+extern int no_empty_command_completion;
+extern int force_fignore;
+extern int dircomplete_spelling, dircomplete_expand;
+extern int complete_fullquote;
+
+extern int enable_hostname_completion __P((int));
+#endif
+
+#if defined (PROGRAMMABLE_COMPLETION)
+extern int prog_completion_enabled;
+#endif
+
+#if defined (RESTRICTED_SHELL)
+extern char *shell_name;
+#endif
+
+#if defined (DEBUGGER)
+extern int debugging_mode;
+#endif
+
+static void shopt_error __P((char *));
+
+static int set_shellopts_after_change __P((char *, int));
+static int shopt_enable_hostname_completion __P((char *, int));
+static int set_compatibility_level __P((char *, int));
+
+#if defined (RESTRICTED_SHELL)
+static int set_restricted_shell __P((char *, int));
+#endif
+
+#if defined (READLINE)
+static int shopt_set_complete_direxpand __P((char *, int));
+#endif
+
+static int shopt_login_shell;
+static int shopt_compat31;
+static int shopt_compat32;
+static int shopt_compat40;
+static int shopt_compat41;
+static int shopt_compat42;
+
+typedef int shopt_set_func_t __P((char *, int));
+
+static struct {
+ char *name;
+ int *value;
+ shopt_set_func_t *set_func;
+} shopt_vars[] = {
+ { "autocd", &autocd, (shopt_set_func_t *)NULL },
+ { "cdable_vars", &cdable_vars, (shopt_set_func_t *)NULL },
+ { "cdspell", &cdspelling, (shopt_set_func_t *)NULL },
+ { "checkhash", &check_hashed_filenames, (shopt_set_func_t *)NULL },
+#if defined (JOB_CONTROL)
+ { "checkjobs", &check_jobs_at_exit, (shopt_set_func_t *)NULL },
+#endif
+ { "checkwinsize", &check_window_size, (shopt_set_func_t *)NULL },
+#if defined (HISTORY)
+ { "cmdhist", &command_oriented_history, (shopt_set_func_t *)NULL },
+#endif
+ { "compat31", &shopt_compat31, set_compatibility_level },
+ { "compat32", &shopt_compat32, set_compatibility_level },
+ { "compat40", &shopt_compat40, set_compatibility_level },
+ { "compat41", &shopt_compat41, set_compatibility_level },
+ { "compat42", &shopt_compat41, set_compatibility_level },
+#if defined (READLINE)
+ { "complete_fullquote", &complete_fullquote, (shopt_set_func_t *)NULL},
+ { "direxpand", &dircomplete_expand, shopt_set_complete_direxpand },
+ { "dirspell", &dircomplete_spelling, (shopt_set_func_t *)NULL },
+#endif
+ { "dotglob", &glob_dot_filenames, (shopt_set_func_t *)NULL },
+ { "execfail", &no_exit_on_failed_exec, (shopt_set_func_t *)NULL },
+ { "expand_aliases", &expand_aliases, (shopt_set_func_t *)NULL },
+#if defined (DEBUGGER)
+ { "extdebug", &debugging_mode, (shopt_set_func_t *)NULL },
+#endif
+#if defined (EXTENDED_GLOB)
+ { "extglob", &extended_glob, (shopt_set_func_t *)NULL },
+#endif
+ { "extquote", &extended_quote, (shopt_set_func_t *)NULL },
+ { "failglob", &fail_glob_expansion, (shopt_set_func_t *)NULL },
+#if defined (READLINE)
+ { "force_fignore", &force_fignore, (shopt_set_func_t *)NULL },
+#endif
+ { "globasciiranges", &glob_asciirange, (shopt_set_func_t *)NULL },
+ { "globstar", &glob_star, (shopt_set_func_t *)NULL },
+ { "gnu_errfmt", &gnu_error_format, (shopt_set_func_t *)NULL },
+#if defined (HISTORY)
+ { "histappend", &force_append_history, (shopt_set_func_t *)NULL },
+#endif
+#if defined (READLINE)
+ { "histreedit", &history_reediting, (shopt_set_func_t *)NULL },
+ { "histverify", &hist_verify, (shopt_set_func_t *)NULL },
+ { "hostcomplete", &perform_hostname_completion, shopt_enable_hostname_completion },
+#endif
+ { "huponexit", &hup_on_exit, (shopt_set_func_t *)NULL },
+ { "interactive_comments", &interactive_comments, set_shellopts_after_change },
+ { "lastpipe", &lastpipe_opt, (shopt_set_func_t *)NULL },
+#if defined (HISTORY)
+ { "lithist", &literal_history, (shopt_set_func_t *)NULL },
+#endif
+ { "login_shell", &shopt_login_shell, set_login_shell },
+ { "mailwarn", &mail_warning, (shopt_set_func_t *)NULL },
+#if defined (READLINE)
+ { "no_empty_cmd_completion", &no_empty_command_completion, (shopt_set_func_t *)NULL },
+#endif
+ { "nocaseglob", &glob_ignore_case, (shopt_set_func_t *)NULL },
+ { "nocasematch", &match_ignore_case, (shopt_set_func_t *)NULL },
+ { "nullglob", &allow_null_glob_expansion, (shopt_set_func_t *)NULL },
+#if defined (PROGRAMMABLE_COMPLETION)
+ { "progcomp", &prog_completion_enabled, (shopt_set_func_t *)NULL },
+#endif
+ { "promptvars", &promptvars, (shopt_set_func_t *)NULL },
+#if defined (RESTRICTED_SHELL)
+ { "restricted_shell", &restricted_shell, set_restricted_shell },
+#endif
+ { "shift_verbose", &print_shift_error, (shopt_set_func_t *)NULL },
+ { "sourcepath", &source_uses_path, (shopt_set_func_t *)NULL },
+ { "xpg_echo", &xpg_echo, (shopt_set_func_t *)NULL },
+ { (char *)0, (int *)0, (shopt_set_func_t *)NULL }
+};
+
+#define N_SHOPT_OPTIONS (sizeof (shopt_vars) / sizeof (shopt_vars[0]))
+
+#define GET_SHOPT_OPTION_VALUE(i) (*shopt_vars[i].value)
+
+static const char * const on = "on";
+static const char * const off = "off";
+
+static int find_shopt __P((char *));
+static int toggle_shopts __P((int, WORD_LIST *, int));
+static void print_shopt __P((char *, int, int));
+static int list_shopts __P((WORD_LIST *, int));
+static int list_some_shopts __P((int, int));
+static int list_shopt_o_options __P((WORD_LIST *, int));
+static int list_some_o_options __P((int, int));
+static int set_shopt_o_options __P((int, WORD_LIST *, int));
+
+#define SFLAG 0x01
+#define UFLAG 0x02
+#define QFLAG 0x04
+#define OFLAG 0x08
+#define PFLAG 0x10
+
+int
+shopt_builtin (list)
+ WORD_LIST *list;
+{
+ int opt, flags, rval;
+
+ flags = 0;
+ reset_internal_getopt ();
+ while ((opt = internal_getopt (list, "psuoq")) != -1)
+ {
+ switch (opt)
+ {
+ case 's':
+ flags |= SFLAG;
+ break;
+ case 'u':
+ flags |= UFLAG;
+ break;
+ case 'q':
+ flags |= QFLAG;
+ break;
+ case 'o':
+ flags |= OFLAG;
+ break;
+ case 'p':
+ flags |= PFLAG;
+ break;
+ default:
+ builtin_usage ();
+ return (EX_USAGE);
+ }
+ }
+ list = loptend;
+
+ if ((flags & (SFLAG|UFLAG)) == (SFLAG|UFLAG))
+ {
+ builtin_error (_("cannot set and unset shell options simultaneously"));
+ return (EXECUTION_FAILURE);
+ }
+
+ rval = EXECUTION_SUCCESS;
+ if ((flags & OFLAG) && ((flags & (SFLAG|UFLAG)) == 0)) /* shopt -o */
+ rval = list_shopt_o_options (list, flags);
+ else if (list && (flags & OFLAG)) /* shopt -so args */
+ rval = set_shopt_o_options ((flags & SFLAG) ? FLAG_ON : FLAG_OFF, list, flags & QFLAG);
+ else if (flags & OFLAG) /* shopt -so */
+ rval = list_some_o_options ((flags & SFLAG) ? 1 : 0, flags);
+ else if (list && (flags & (SFLAG|UFLAG))) /* shopt -su args */
+ rval = toggle_shopts ((flags & SFLAG) ? SETOPT : UNSETOPT, list, flags & QFLAG);
+ else if ((flags & (SFLAG|UFLAG)) == 0) /* shopt [args] */
+ rval = list_shopts (list, flags);
+ else /* shopt -su */
+ rval = list_some_shopts ((flags & SFLAG) ? SETOPT : UNSETOPT, flags);
+ return (rval);
+}
+
+/* Reset the options managed by `shopt' to the values they would have at
+ shell startup. */
+void
+reset_shopt_options ()
+{
+ allow_null_glob_expansion = glob_dot_filenames = 0;
+ cdable_vars = mail_warning = 0;
+ no_exit_on_failed_exec = print_shift_error = 0;
+ check_hashed_filenames = cdspelling = expand_aliases = 0;
+
+ source_uses_path = promptvars = 1;
+
+ check_window_size = CHECKWINSIZE_DEFAULT;
+
+#if defined (EXTENDED_GLOB)
+ extended_glob = 0;
+#endif
+
+#if defined (HISTORY)
+ literal_history = force_append_history = 0;
+ command_oriented_history = 1;
+#endif
+
+#if defined (READLINE)
+ hist_verify = history_reediting = 0;
+ perform_hostname_completion = 1;
+#endif
+
+ shopt_login_shell = login_shell;
+}
+
+static int
+find_shopt (name)
+ char *name;
+{
+ int i;
+
+ for (i = 0; shopt_vars[i].name; i++)
+ if (STREQ (name, shopt_vars[i].name))
+ return i;
+ return -1;
+}
+
+static void
+shopt_error (s)
+ char *s;
+{
+ builtin_error (_("%s: invalid shell option name"), s);
+}
+
+static int
+toggle_shopts (mode, list, quiet)
+ int mode;
+ WORD_LIST *list;
+ int quiet;
+{
+ WORD_LIST *l;
+ int ind, rval;
+
+ for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next)
+ {
+ ind = find_shopt (l->word->word);
+ if (ind < 0)
+ {
+ shopt_error (l->word->word);
+ rval = EXECUTION_FAILURE;
+ }
+ else
+ {
+ *shopt_vars[ind].value = mode; /* 1 for set, 0 for unset */
+ if (shopt_vars[ind].set_func)
+ (*shopt_vars[ind].set_func) (shopt_vars[ind].name, mode);
+ }
+ }
+
+ set_bashopts ();
+ return (rval);
+}
+
+static void
+print_shopt (name, val, flags)
+ char *name;
+ int val, flags;
+{
+ if (flags & PFLAG)
+ printf ("shopt %s %s\n", val ? "-s" : "-u", name);
+ else
+ printf (OPTFMT, name, val ? on : off);
+}
+
+/* List the values of all or any of the `shopt' options. Returns 0 if
+ all were listed or all variables queried were on; 1 otherwise. */
+static int
+list_shopts (list, flags)
+ WORD_LIST *list;
+ int flags;
+{
+ WORD_LIST *l;
+ int i, val, rval;
+
+ if (list == 0)
+ {
+ for (i = 0; shopt_vars[i].name; i++)
+ {
+ val = *shopt_vars[i].value;
+ if ((flags & QFLAG) == 0)
+ print_shopt (shopt_vars[i].name, val, flags);
+ }
+ return (sh_chkwrite (EXECUTION_SUCCESS));
+ }
+
+ for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next)
+ {
+ i = find_shopt (l->word->word);
+ if (i < 0)
+ {
+ shopt_error (l->word->word);
+ rval = EXECUTION_FAILURE;
+ continue;
+ }
+ val = *shopt_vars[i].value;
+ if (val == 0)
+ rval = EXECUTION_FAILURE;
+ if ((flags & QFLAG) == 0)
+ print_shopt (l->word->word, val, flags);
+ }
+
+ return (sh_chkwrite (rval));
+}
+
+static int
+list_some_shopts (mode, flags)
+ int mode, flags;
+{
+ int val, i;
+
+ for (i = 0; shopt_vars[i].name; i++)
+ {
+ val = *shopt_vars[i].value;
+ if (((flags & QFLAG) == 0) && mode == val)
+ print_shopt (shopt_vars[i].name, val, flags);
+ }
+ return (sh_chkwrite (EXECUTION_SUCCESS));
+}
+
+static int
+list_shopt_o_options (list, flags)
+ WORD_LIST *list;
+ int flags;
+{
+ WORD_LIST *l;
+ int val, rval;
+
+ if (list == 0)
+ {
+ if ((flags & QFLAG) == 0)
+ list_minus_o_opts (-1, (flags & PFLAG));
+ return (sh_chkwrite (EXECUTION_SUCCESS));
+ }
+
+ for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next)
+ {
+ val = minus_o_option_value (l->word->word);
+ if (val == -1)
+ {
+ sh_invalidoptname (l->word->word);
+ rval = EXECUTION_FAILURE;
+ continue;
+ }
+ if (val == 0)
+ rval = EXECUTION_FAILURE;
+ if ((flags & QFLAG) == 0)
+ {
+ if (flags & PFLAG)
+ printf ("set %co %s\n", val ? '-' : '+', l->word->word);
+ else
+ printf (OPTFMT, l->word->word, val ? on : off);
+ }
+ }
+ return (sh_chkwrite (rval));
+}
+
+static int
+list_some_o_options (mode, flags)
+ int mode, flags;
+{
+ if ((flags & QFLAG) == 0)
+ list_minus_o_opts (mode, (flags & PFLAG));
+ return (sh_chkwrite (EXECUTION_SUCCESS));
+}
+
+static int
+set_shopt_o_options (mode, list, quiet)
+ int mode;
+ WORD_LIST *list;
+ int quiet;
+{
+ WORD_LIST *l;
+ int rval;
+
+ for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next)
+ {
+ if (set_minus_o_option (mode, l->word->word) == EXECUTION_FAILURE)
+ rval = EXECUTION_FAILURE;
+ }
+ set_shellopts ();
+ return rval;
+}
+
+/* If we set or unset interactive_comments with shopt, make sure the
+ change is reflected in $SHELLOPTS. */
+static int
+set_shellopts_after_change (option_name, mode)
+ char *option_name;
+ int mode;
+{
+ set_shellopts ();
+ return (0);
+}
+
+static int
+shopt_enable_hostname_completion (option_name, mode)
+ char *option_name;
+ int mode;
+{
+ return (enable_hostname_completion (mode));
+}
+
+static int
+set_compatibility_level (option_name, mode)
+ char *option_name;
+ int mode;
+{
+ int ind;
+
+ /* If we're setting something, redo some of the work we did above in
+ toggle_shopt(). Unset everything and reset the appropriate option
+ based on OPTION_NAME. */
+ if (mode)
+ {
+ shopt_compat31 = shopt_compat32 = 0;
+ shopt_compat40 = shopt_compat41 = shopt_compat42 = 0;
+ ind = find_shopt (option_name);
+ *shopt_vars[ind].value = mode;
+ }
+
+ /* Then set shell_compatibility_level based on what remains */
+ if (shopt_compat31)
+ shell_compatibility_level = 31;
+ else if (shopt_compat32)
+ shell_compatibility_level = 32;
+ else if (shopt_compat40)
+ shell_compatibility_level = 40;
+ else if (shopt_compat41)
+ shell_compatibility_level = 41;
+ else if (shopt_compat42)
+ shell_compatibility_level = 42;
+ else
+ shell_compatibility_level = DEFAULT_COMPAT_LEVEL;
+
+ return 0;
+}
+
+/* Set and unset the various compatibility options from the value of
+ shell_compatibility_level; used by sv_shcompat */
+void
+set_compatibility_opts ()
+{
+ shopt_compat31 = shopt_compat32 = shopt_compat40 = shopt_compat41 = shopt_compat42 = 0;
+ switch (shell_compatibility_level)
+ {
+ case DEFAULT_COMPAT_LEVEL:
+ break;
+ case 42:
+ shopt_compat42 = 1; break;
+ case 41:
+ shopt_compat41 = 1; break;
+ case 40:
+ shopt_compat40 = 1; break;
+ case 32:
+ shopt_compat32 = 1; break;
+ case 31:
+ shopt_compat31 = 1; break;
+ }
+}
+
+#if defined (READLINE)
+static int
+shopt_set_complete_direxpand (option_name, mode)
+ char *option_name;
+ int mode;
+{
+ set_directory_hook ();
+ return 0;
+}
+#endif
+
+#if defined (RESTRICTED_SHELL)
+/* Don't allow the value of restricted_shell to be modified. */
+
+static int
+set_restricted_shell (option_name, mode)
+ char *option_name;
+ int mode;
+{
+ static int save_restricted = -1;
+
+ if (save_restricted == -1)
+ save_restricted = shell_is_restricted (shell_name);
+
+ restricted_shell = save_restricted;
+ return (0);
+}
+#endif /* RESTRICTED_SHELL */
+
+/* Not static so shell.c can call it to initialize shopt_login_shell */
+int
+set_login_shell (option_name, mode)
+ char *option_name;
+ int mode;
+{
+ shopt_login_shell = login_shell != 0;
+ return (0);
+}
+
+char **
+get_shopt_options ()
+{
+ char **ret;
+ int n, i;
+
+ n = sizeof (shopt_vars) / sizeof (shopt_vars[0]);
+ ret = strvec_create (n + 1);
+ for (i = 0; shopt_vars[i].name; i++)
+ ret[i] = savestring (shopt_vars[i].name);
+ ret[i] = (char *)NULL;
+ return ret;
+}
+
+/*
+ * External interface for other parts of the shell. NAME is a string option;
+ * MODE is 0 if we want to unset an option; 1 if we want to set an option.
+ * REUSABLE is 1 if we want to print output in a form that may be reused.
+ */
+int
+shopt_setopt (name, mode)
+ char *name;
+ int mode;
+{
+ WORD_LIST *wl;
+ int r;
+
+ wl = add_string_to_list (name, (WORD_LIST *)NULL);
+ r = toggle_shopts (mode, wl, 0);
+ dispose_words (wl);
+ return r;
+}
+
+int
+shopt_listopt (name, reusable)
+ char *name;
+ int reusable;
+{
+ int i;
+
+ if (name == 0)
+ return (list_shopts ((WORD_LIST *)NULL, reusable ? PFLAG : 0));
+
+ i = find_shopt (name);
+ if (i < 0)
+ {
+ shopt_error (name);
+ return (EXECUTION_FAILURE);
+ }
+
+ print_shopt (name, *shopt_vars[i].value, reusable ? PFLAG : 0);
+ return (sh_chkwrite (EXECUTION_SUCCESS));
+}
+
+void
+set_bashopts ()
+{
+ char *value;
+ char tflag[N_SHOPT_OPTIONS];
+ int vsize, i, vptr, *ip, exported;
+ SHELL_VAR *v;
+
+ for (vsize = i = 0; shopt_vars[i].name; i++)
+ {
+ tflag[i] = 0;
+ if (GET_SHOPT_OPTION_VALUE (i))
+ {
+ vsize += strlen (shopt_vars[i].name) + 1;
+ tflag[i] = 1;
+ }
+ }
+
+ value = (char *)xmalloc (vsize + 1);
+
+ for (i = vptr = 0; shopt_vars[i].name; i++)
+ {
+ if (tflag[i])
+ {
+ strcpy (value + vptr, shopt_vars[i].name);
+ vptr += strlen (shopt_vars[i].name);
+ value[vptr++] = ':';
+ }
+ }
+
+ if (vptr)
+ vptr--; /* cut off trailing colon */
+ value[vptr] = '\0';
+
+ v = find_variable ("BASHOPTS");
+
+ /* Turn off the read-only attribute so we can bind the new value, and
+ note whether or not the variable was exported. */
+ if (v)
+ {
+ VUNSETATTR (v, att_readonly);
+ exported = exported_p (v);
+ }
+ else
+ exported = 0;
+
+ v = bind_variable ("BASHOPTS", value, 0);
+
+ /* Turn the read-only attribute back on, and turn off the export attribute
+ if it was set implicitly by mark_modified_vars and SHELLOPTS was not
+ exported before we bound the new value. */
+ VSETATTR (v, att_readonly);
+ if (mark_modified_vars && exported == 0 && exported_p (v))
+ VUNSETATTR (v, att_exported);
+
+ free (value);
+}
+
+void
+parse_bashopts (value)
+ char *value;
+{
+ char *vname;
+ int vptr, ind;
+
+ vptr = 0;
+ while (vname = extract_colon_unit (value, &vptr))
+ {
+ ind = find_shopt (vname);
+ if (ind >= 0)
+ *shopt_vars[ind].value = 1;
+ free (vname);
+ }
+}
+
+void
+initialize_bashopts (no_bashopts)
+ int no_bashopts;
+{
+ char *temp;
+ SHELL_VAR *var;
+
+ if (no_bashopts == 0)
+ {
+ var = find_variable ("BASHOPTS");
+ /* set up any shell options we may have inherited. */
+ if (var && imported_p (var))
+ {
+ temp = (array_p (var) || assoc_p (var)) ? (char *)NULL : savestring (value_cell (var));
+ if (temp)
+ {
+ parse_bashopts (temp);
+ free (temp);
+ }
+ }
+ }
+
+ /* Set up the $BASHOPTS variable. */
+ set_bashopts ();
+}
--- /dev/null
+/* rltty.c -- functions to prepare and restore the terminal for readline's
+ use. */
+
+/* Copyright (C) 1992-2005 Free Software Foundation, Inc.
+
+ This file is part of the GNU Readline Library (Readline), a library
+ for reading lines of text with interactive input and history editing.
+
+ 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 3 of the License, or
+ (at your option) any later version.
+
+ Readline 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 Readline. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#define READLINE_LIBRARY
+
+#if defined (HAVE_CONFIG_H)
+# include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <signal.h>
+#include <errno.h>
+#include <stdio.h>
+
+#if defined (HAVE_UNISTD_H)
+# include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#include "rldefs.h"
+
+#if defined (GWINSZ_IN_SYS_IOCTL)
+# include <sys/ioctl.h>
+#endif /* GWINSZ_IN_SYS_IOCTL */
+
+#include "rltty.h"
+#include "readline.h"
+#include "rlprivate.h"
+
+#if !defined (errno)
+extern int errno;
+#endif /* !errno */
+
+rl_vintfunc_t *rl_prep_term_function = rl_prep_terminal;
+rl_voidfunc_t *rl_deprep_term_function = rl_deprep_terminal;
+
+static void set_winsize PARAMS((int));
+
+/* **************************************************************** */
+/* */
+/* Saving and Restoring the TTY */
+/* */
+/* **************************************************************** */
+
+/* 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
+
+/* 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 (NO_TTY_DRIVER)
+/* Nothing */
+#elif defined (NEW_TTY_DRIVER)
+
+/* Values for the `flags' field of a struct bsdtty. This tells which
+ elements of the struct bsdtty have been fetched from the system and
+ are valid. */
+#define SGTTY_SET 0x01
+#define LFLAG_SET 0x02
+#define TCHARS_SET 0x04
+#define LTCHARS_SET 0x08
+
+struct bsdtty {
+ struct sgttyb sgttyb; /* Basic BSD tty driver information. */
+ int lflag; /* Local mode flags, like LPASS8. */
+#if defined (TIOCGETC)
+ struct tchars tchars; /* Terminal special characters, including ^S and ^Q. */
+#endif
+#if defined (TIOCGLTC)
+ struct ltchars ltchars; /* 4.2 BSD editing characters */
+#endif
+ int flags; /* Bitmap saying which parts of the struct are valid. */
+};
+
+#define TIOTYPE struct bsdtty
+
+static TIOTYPE otio;
+
+static void save_tty_chars PARAMS((TIOTYPE *));
+static int _get_tty_settings PARAMS((int, TIOTYPE *));
+static int get_tty_settings PARAMS((int, TIOTYPE *));
+static int _set_tty_settings PARAMS((int, TIOTYPE *));
+static int set_tty_settings PARAMS((int, TIOTYPE *));
+
+static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
+
+static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t *));
+
+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_intr_char = _rl_tty_chars.t_intr = tiop->tchars.t_intrc;
+ _rl_quit_char = _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_susp_char = _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;
+ TIOTYPE *tiop;
+{
+ set_winsize (tty);
+
+ tiop->flags = tiop->lflag = 0;
+
+ errno = 0;
+ if (ioctl (tty, TIOCGETP, &(tiop->sgttyb)) < 0)
+ return -1;
+ tiop->flags |= SGTTY_SET;
+
+#if defined (TIOCLGET)
+ if (ioctl (tty, TIOCLGET, &(tiop->lflag)) == 0)
+ tiop->flags |= LFLAG_SET;
+#endif
+
+#if defined (TIOCGETC)
+ if (ioctl (tty, TIOCGETC, &(tiop->tchars)) == 0)
+ tiop->flags |= TCHARS_SET;
+#endif
+
+#if defined (TIOCGLTC)
+ if (ioctl (tty, TIOCGLTC, &(tiop->ltchars)) == 0)
+ tiop->flags |= LTCHARS_SET;
+#endif
+
+ return 0;
+}
+
+static int
+set_tty_settings (tty, tiop)
+ int tty;
+ TIOTYPE *tiop;
+{
+ if (tiop->flags & SGTTY_SET)
+ {
+ ioctl (tty, TIOCSETN, &(tiop->sgttyb));
+ tiop->flags &= ~SGTTY_SET;
+ }
+ _rl_echoing_p = 1;
+
+#if defined (TIOCLSET)
+ if (tiop->flags & LFLAG_SET)
+ {
+ ioctl (tty, TIOCLSET, &(tiop->lflag));
+ tiop->flags &= ~LFLAG_SET;
+ }
+#endif
+
+#if defined (TIOCSETC)
+ if (tiop->flags & TCHARS_SET)
+ {
+ ioctl (tty, TIOCSETC, &(tiop->tchars));
+ tiop->flags &= ~TCHARS_SET;
+ }
+#endif
+
+#if defined (TIOCSLTC)
+ if (tiop->flags & LTCHARS_SET)
+ {
+ ioctl (tty, TIOCSLTC, &(tiop->ltchars));
+ tiop->flags &= ~LTCHARS_SET;
+ }
+#endif
+
+ return 0;
+}
+
+static void
+prepare_terminal_settings (meta_flag, oldtio, tiop)
+ int meta_flag;
+ TIOTYPE oldtio, *tiop;
+{
+ _rl_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
+ _rl_echoctl = (oldtio.sgttyb.sg_flags & ECHOCTL);
+
+ /* Copy the original settings to the structure we're going to use for
+ our settings. */
+ tiop->sgttyb = oldtio.sgttyb;
+ tiop->lflag = oldtio.lflag;
+#if defined (TIOCGETC)
+ tiop->tchars = oldtio.tchars;
+#endif
+#if defined (TIOCGLTC)
+ tiop->ltchars = oldtio.ltchars;
+#endif
+ tiop->flags = oldtio.flags;
+
+ /* First, the basic settings to put us into character-at-a-time, no-echo
+ input mode. */
+ tiop->sgttyb.sg_flags &= ~(ECHO | CRMOD);
+ tiop->sgttyb.sg_flags |= CBREAK;
+
+ /* If this terminal doesn't care how the 8th bit is used, then we can
+ use it for the meta-key. If only one of even or odd parity is
+ specified, then the terminal is using parity, and we cannot. */
+#if !defined (ANYP)
+# define ANYP (EVENP | ODDP)
+#endif
+ if (((oldtio.sgttyb.sg_flags & ANYP) == ANYP) ||
+ ((oldtio.sgttyb.sg_flags & ANYP) == 0))
+ {
+ tiop->sgttyb.sg_flags |= ANYP;
+
+ /* Hack on local mode flags if we can. */
+#if defined (TIOCLGET)
+# if defined (LPASS8)
+ tiop->lflag |= LPASS8;
+# endif /* LPASS8 */
+#endif /* TIOCLGET */
+ }
+
+#if defined (TIOCGETC)
+# if defined (USE_XON_XOFF)
+ /* Get rid of terminal output start and stop characters. */
+ tiop->tchars.t_stopc = -1; /* C-s */
+ tiop->tchars.t_startc = -1; /* C-q */
+
+ /* If there is an XON character, bind it to restart the output. */
+ if (oldtio.tchars.t_startc != -1)
+ rl_bind_key (oldtio.tchars.t_startc, rl_restart_output);
+# endif /* USE_XON_XOFF */
+
+ /* If there is an EOF char, bind _rl_eof_char to it. */
+ if (oldtio.tchars.t_eofc != -1)
+ _rl_eof_char = oldtio.tchars.t_eofc;
+
+# if defined (NO_KILL_INTR)
+ /* Get rid of terminal-generated SIGQUIT and SIGINT. */
+ tiop->tchars.t_quitc = -1; /* C-\ */
+ tiop->tchars.t_intrc = -1; /* C-c */
+# endif /* NO_KILL_INTR */
+#endif /* TIOCGETC */
+
+#if defined (TIOCGLTC)
+ /* Make the interrupt keys go away. Just enough to make people happy. */
+ tiop->ltchars.t_dsuspc = -1; /* C-y */
+ tiop->ltchars.t_lnextc = -1; /* C-v */
+#endif /* TIOCGLTC */
+}
+
+#else /* !defined (NEW_TTY_DRIVER) */
+
+#if !defined (VMIN)
+# define VMIN VEOF
+#endif
+
+#if !defined (VTIME)
+# define VTIME VEOL
+#endif
+
+#if defined (TERMIOS_TTY_DRIVER)
+# define TIOTYPE struct termios
+# define DRAIN_OUTPUT(fd) tcdrain (fd)
+# define GETATTR(tty, tiop) (tcgetattr (tty, tiop))
+# ifdef M_UNIX
+# define SETATTR(tty, tiop) (tcsetattr (tty, TCSANOW, tiop))
+# else
+# define SETATTR(tty, tiop) (tcsetattr (tty, TCSADRAIN, tiop))
+# endif /* !M_UNIX */
+#else
+# define TIOTYPE struct termio
+# define DRAIN_OUTPUT(fd)
+# define GETATTR(tty, tiop) (ioctl (tty, TCGETA, tiop))
+# define SETATTR(tty, tiop) (ioctl (tty, TCSETAW, tiop))
+#endif /* !TERMIOS_TTY_DRIVER */
+
+static TIOTYPE otio;
+
+static void save_tty_chars PARAMS((TIOTYPE *));
+static int _get_tty_settings PARAMS((int, TIOTYPE *));
+static int get_tty_settings PARAMS((int, TIOTYPE *));
+static int _set_tty_settings PARAMS((int, TIOTYPE *));
+static int set_tty_settings PARAMS((int, TIOTYPE *));
+
+static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
+
+static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t *));
+static void _rl_bind_tty_special_chars PARAMS((Keymap, TIOTYPE));
+
+#if defined (FLUSHO)
+# define OUTPUT_BEING_FLUSHED(tp) (tp->c_lflag & FLUSHO)
+#else
+# define OUTPUT_BEING_FLUSHED(tp) 0
+#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_intr_char = _rl_tty_chars.t_intr = tiop->c_cc[VINTR];
+ _rl_quit_char = _rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
+#ifdef VSUSP
+ _rl_susp_char = _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;
+{
+ _rl_errmsg ("warning: %s", msg);
+}
+#endif
+
+#if defined (_AIX)
+void
+setopost(tp)
+TIOTYPE *tp;
+{
+ if ((tp->c_oflag & OPOST) == 0)
+ {
+ _rl_errmsg ("warning: turning on OPOST for terminal\r");
+ tp->c_oflag |= OPOST|ONLCR;
+ }
+}
+#endif
+
+static int
+_get_tty_settings (tty, tiop)
+ int tty;
+ TIOTYPE *tiop;
+{
+ int ioctl_ret;
+
+ while (1)
+ {
+ ioctl_ret = GETATTR (tty, tiop);
+ if (ioctl_ret < 0)
+ {
+ if (errno != EINTR)
+ return -1;
+ else
+ continue;
+ }
+ if (OUTPUT_BEING_FLUSHED (tiop))
+ {
+#if defined (FLUSHO)
+ _rl_errmsg ("warning: turning off output flushing");
+ tiop->c_lflag &= ~FLUSHO;
+ break;
+#else
+ continue;
+#endif
+ }
+ break;
+ }
+
+ return 0;
+}
+
+static int
+get_tty_settings (tty, tiop)
+ int tty;
+ TIOTYPE *tiop;
+{
+ set_winsize (tty);
+
+ errno = 0;
+ if (_get_tty_settings (tty, tiop) < 0)
+ return -1;
+
+#if defined (_AIX)
+ setopost(tiop);
+#endif
+
+ return 0;
+}
+
+static int
+_set_tty_settings (tty, tiop)
+ int tty;
+ TIOTYPE *tiop;
+{
+ while (SETATTR (tty, tiop) < 0)
+ {
+ if (errno != EINTR)
+ 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)
+# if defined (__ksr1__)
+ if (ksrflow)
+ {
+ ksrflow = 0;
+ tcflow (tty, TCOON);
+ }
+# else /* !ksr1 */
+ tcflow (tty, TCOON); /* Simulate a ^Q. */
+# endif /* !ksr1 */
+#else
+ ioctl (tty, TCXONC, 1); /* Simulate a ^Q. */
+#endif /* !TERMIOS_TTY_DRIVER */
+
+#endif /* 0 */
+
+ return 0;
+}
+
+static void
+prepare_terminal_settings (meta_flag, oldtio, tiop)
+ int meta_flag;
+ TIOTYPE oldtio, *tiop;
+{
+ _rl_echoing_p = (oldtio.c_lflag & ECHO);
+#if defined (ECHOCTL)
+ _rl_echoctl = (oldtio.c_lflag & ECHOCTL);
+#endif
+
+ tiop->c_lflag &= ~(ICANON | ECHO);
+
+ if ((unsigned char) oldtio.c_cc[VEOF] != (unsigned char) _POSIX_VDISABLE)
+ _rl_eof_char = oldtio.c_cc[VEOF];
+
+#if defined (USE_XON_XOFF)
+#if defined (IXANY)
+ tiop->c_iflag &= ~(IXON | IXANY);
+#else
+ /* `strict' Posix systems do not define IXANY. */
+ tiop->c_iflag &= ~IXON;
+#endif /* IXANY */
+#endif /* USE_XON_XOFF */
+
+ /* Only turn this off if we are using all 8 bits. */
+ if (((tiop->c_cflag & CSIZE) == CS8) || meta_flag)
+ tiop->c_iflag &= ~(ISTRIP | INPCK);
+
+ /* Make sure we differentiate between CR and NL on input. */
+ tiop->c_iflag &= ~(ICRNL | INLCR);
+
+#if !defined (HANDLE_SIGNALS)
+ tiop->c_lflag &= ~ISIG;
+#else
+ tiop->c_lflag |= ISIG;
+#endif
+
+ tiop->c_cc[VMIN] = 1;
+ tiop->c_cc[VTIME] = 0;
+
+#if defined (FLUSHO)
+ if (OUTPUT_BEING_FLUSHED (tiop))
+ {
+ tiop->c_lflag &= ~FLUSHO;
+ oldtio.c_lflag &= ~FLUSHO;
+ }
+#endif
+
+ /* Turn off characters that we need on Posix systems with job control,
+ just to be sure. This includes ^Y and ^V. This should not really
+ be necessary. */
+#if defined (TERMIOS_TTY_DRIVER) && defined (_POSIX_VDISABLE)
+
+#if defined (VLNEXT)
+ tiop->c_cc[VLNEXT] = _POSIX_VDISABLE;
+#endif
+
+#if defined (VDSUSP)
+ tiop->c_cc[VDSUSP] = _POSIX_VDISABLE;
+#endif
+
+#endif /* TERMIOS_TTY_DRIVER && _POSIX_VDISABLE */
+}
+#endif /* !NEW_TTY_DRIVER */
+
+/* Put the terminal in CBREAK mode so that we can detect key presses. */
+#if defined (NO_TTY_DRIVER)
+void
+rl_prep_terminal (meta_flag)
+ int meta_flag;
+{
+ _rl_echoing_p = 1;
+}
+
+void
+rl_deprep_terminal ()
+{
+}
+
+#else /* ! NO_TTY_DRIVER */
+void
+rl_prep_terminal (meta_flag)
+ int meta_flag;
+{
+ int tty;
+ TIOTYPE tio;
+
+ if (terminal_prepped)
+ return;
+itrace("rl_prep_terminal");
+ /* Try to keep this function from being INTerrupted. */
+ _rl_block_sigint ();
+
+ tty = rl_instream ? fileno (rl_instream) : fileno (stdin);
+
+ if (get_tty_settings (tty, &tio) < 0)
+ {
+#if defined (ENOTSUP)
+ /* MacOS X and Linux, at least, lie about the value of errno if
+ tcgetattr fails. */
+ if (errno == ENOTTY || errno == EINVAL || errno == ENOTSUP)
+#else
+ if (errno == ENOTTY || errno == EINVAL)
+#endif
+ _rl_echoing_p = 1; /* XXX */
+
+ _rl_release_sigint ();
+ return;
+ }
+
+ otio = tio;
+
+ if (_rl_bind_stty_chars)
+ {
+#if defined (VI_MODE)
+ /* If editing in vi mode, make sure we restore the bindings in the
+ insertion keymap no matter what keymap we ended up in. */
+ if (rl_editing_mode == vi_mode)
+ rl_tty_unset_default_bindings (vi_insertion_keymap);
+ else
+#endif
+ rl_tty_unset_default_bindings (_rl_keymap);
+ }
+ save_tty_chars (&otio);
+ RL_SETSTATE(RL_STATE_TTYCSAVED);
+ if (_rl_bind_stty_chars)
+ {
+#if defined (VI_MODE)
+ /* If editing in vi mode, make sure we set the bindings in the
+ insertion keymap no matter what keymap we ended up in. */
+ if (rl_editing_mode == vi_mode)
+ _rl_bind_tty_special_chars (vi_insertion_keymap, tio);
+ else
+#endif
+ _rl_bind_tty_special_chars (_rl_keymap, tio);
+ }
+
+ prepare_terminal_settings (meta_flag, otio, &tio);
+
+ if (set_tty_settings (tty, &tio) < 0)
+ {
+ _rl_release_sigint ();
+ return;
+ }
+
+ if (_rl_enable_keypad)
+ _rl_control_keypad (1);
+
+ fflush (rl_outstream);
+ terminal_prepped = 1;
+ RL_SETSTATE(RL_STATE_TERMPREPPED);
+
+ _rl_release_sigint ();
+}
+
+/* Restore the terminal's normal settings and modes. */
+void
+rl_deprep_terminal ()
+{
+ int tty;
+
+ if (!terminal_prepped)
+ return;
+itrace("rl_deprep_terminal");
+ /* Try to keep this function from being interrupted. */
+ _rl_block_sigint ();
+
+ tty = rl_instream ? fileno (rl_instream) : fileno (stdin);
+
+ if (_rl_enable_keypad)
+ _rl_control_keypad (0);
+
+ fflush (rl_outstream);
+
+ if (set_tty_settings (tty, &otio) < 0)
+ {
+ _rl_release_sigint ();
+ return;
+ }
+
+ terminal_prepped = 0;
+ RL_UNSETSTATE(RL_STATE_TERMPREPPED);
+
+ _rl_release_sigint ();
+}
+#endif /* !NO_TTY_DRIVER */
+\f
+/* **************************************************************** */
+/* */
+/* Bogus Flow Control */
+/* */
+/* **************************************************************** */
+
+int
+rl_restart_output (count, key)
+ int count, key;
+{
+#if defined (__MINGW32__)
+ return 0;
+#else /* !__MING32__ */
+
+ int fildes = fileno (rl_outstream);
+#if defined (TIOCSTART)
+#if defined (apollo)
+ ioctl (&fildes, TIOCSTART, 0);
+#else
+ ioctl (fildes, TIOCSTART, 0);
+#endif /* apollo */
+
+#else /* !TIOCSTART */
+# if defined (TERMIOS_TTY_DRIVER)
+# if defined (__ksr1__)
+ if (ksrflow)
+ {
+ ksrflow = 0;
+ tcflow (fildes, TCOON);
+ }
+# else /* !ksr1 */
+ tcflow (fildes, TCOON); /* Simulate a ^Q. */
+# endif /* !ksr1 */
+# else /* !TERMIOS_TTY_DRIVER */
+# if defined (TCXONC)
+ ioctl (fildes, TCXONC, TCOON);
+# endif /* TCXONC */
+# endif /* !TERMIOS_TTY_DRIVER */
+#endif /* !TIOCSTART */
+
+ return 0;
+#endif /* !__MINGW32__ */
+}
+
+int
+rl_stop_output (count, key)
+ int count, key;
+{
+#if defined (__MINGW32__)
+ return 0;
+#else
+
+ int fildes = fileno (rl_instream);
+
+#if defined (TIOCSTOP)
+# if defined (apollo)
+ ioctl (&fildes, TIOCSTOP, 0);
+# else
+ ioctl (fildes, TIOCSTOP, 0);
+# endif /* apollo */
+#else /* !TIOCSTOP */
+# if defined (TERMIOS_TTY_DRIVER)
+# if defined (__ksr1__)
+ ksrflow = 1;
+# endif /* ksr1 */
+ tcflow (fildes, TCOOFF);
+# else
+# if defined (TCXONC)
+ ioctl (fildes, TCXONC, TCOON);
+# endif /* TCXONC */
+# endif /* !TERMIOS_TTY_DRIVER */
+#endif /* !TIOCSTOP */
+
+ return 0;
+#endif /* !__MINGW32__ */
+}
+
+/* **************************************************************** */
+/* */
+/* Default Key Bindings */
+/* */
+/* **************************************************************** */
+
+#if !defined (NO_TTY_DRIVER)
+#define SET_SPECIAL(sc, func) set_special_char(kmap, &ttybuff, sc, func)
+#endif
+
+#if defined (NO_TTY_DRIVER)
+
+#define SET_SPECIAL(sc, func)
+#define RESET_SPECIAL(c)
+
+#elif defined (NEW_TTY_DRIVER)
+static void
+set_special_char (kmap, tiop, sc, func)
+ Keymap kmap;
+ TIOTYPE *tiop;
+ int sc;
+ rl_command_func_t *func;
+{
+ if (sc != -1 && kmap[(unsigned char)sc].type == ISFUNC)
+ kmap[(unsigned char)sc].function = func;
+}
+
+#define RESET_SPECIAL(c) \
+ if (c != -1 && kmap[(unsigned char)c].type == ISFUNC) \
+ kmap[(unsigned char)c].function = rl_insert;
+
+static void
+_rl_bind_tty_special_chars (kmap, ttybuff)
+ Keymap kmap;
+ TIOTYPE ttybuff;
+{
+ if (ttybuff.flags & SGTTY_SET)
+ {
+ SET_SPECIAL (ttybuff.sgttyb.sg_erase, rl_rubout);
+ SET_SPECIAL (ttybuff.sgttyb.sg_kill, rl_unix_line_discard);
+ }
+
+# if defined (TIOCGLTC)
+ if (ttybuff.flags & LTCHARS_SET)
+ {
+ SET_SPECIAL (ttybuff.ltchars.t_werasc, rl_unix_word_rubout);
+ SET_SPECIAL (ttybuff.ltchars.t_lnextc, rl_quoted_insert);
+ }
+# endif /* TIOCGLTC */
+}
+
+#else /* !NEW_TTY_DRIVER */
+static void
+set_special_char (kmap, tiop, sc, func)
+ Keymap kmap;
+ TIOTYPE *tiop;
+ int sc;
+ rl_command_func_t *func;
+{
+ unsigned char uc;
+
+ uc = tiop->c_cc[sc];
+ if (uc != (unsigned char)_POSIX_VDISABLE && kmap[uc].type == ISFUNC)
+ kmap[uc].function = func;
+}
+
+/* used later */
+#define RESET_SPECIAL(uc) \
+ if (uc != (unsigned char)_POSIX_VDISABLE && kmap[uc].type == ISFUNC) \
+ kmap[uc].function = rl_insert;
+
+static void
+_rl_bind_tty_special_chars (kmap, ttybuff)
+ Keymap kmap;
+ TIOTYPE ttybuff;
+{
+ SET_SPECIAL (VERASE, rl_rubout);
+ SET_SPECIAL (VKILL, rl_unix_line_discard);
+
+# if defined (VLNEXT) && defined (TERMIOS_TTY_DRIVER)
+ SET_SPECIAL (VLNEXT, rl_quoted_insert);
+# endif /* VLNEXT && TERMIOS_TTY_DRIVER */
+
+# if defined (VWERASE) && defined (TERMIOS_TTY_DRIVER)
+ SET_SPECIAL (VWERASE, rl_unix_word_rubout);
+# endif /* VWERASE && TERMIOS_TTY_DRIVER */
+}
+
+#endif /* !NEW_TTY_DRIVER */
+
+/* Set the system's default editing characters to their readline equivalents
+ in KMAP. Should be static, now that we have rl_tty_set_default_bindings. */
+void
+rltty_set_default_bindings (kmap)
+ Keymap kmap;
+{
+#if !defined (NO_TTY_DRIVER)
+ TIOTYPE ttybuff;
+ int tty;
+
+ tty = fileno (rl_instream);
+
+ if (get_tty_settings (tty, &ttybuff) == 0)
+ _rl_bind_tty_special_chars (kmap, ttybuff);
+#endif
+}
+
+/* New public way to set the system default editing chars to their readline
+ equivalents. */
+void
+rl_tty_set_default_bindings (kmap)
+ Keymap kmap;
+{
+ rltty_set_default_bindings (kmap);
+}
+
+/* Rebind all of the tty special chars that readline worries about back
+ to self-insert. Call this before saving the current terminal special
+ chars with save_tty_chars(). This only works on POSIX termios or termio
+ systems. */
+void
+rl_tty_unset_default_bindings (kmap)
+ Keymap kmap;
+{
+ /* Don't bother before we've saved the tty special chars at least once. */
+ if (RL_ISSTATE(RL_STATE_TTYCSAVED) == 0)
+ return;
+
+ RESET_SPECIAL (_rl_tty_chars.t_erase);
+ RESET_SPECIAL (_rl_tty_chars.t_kill);
+
+# if defined (VLNEXT) && defined (TERMIOS_TTY_DRIVER)
+ RESET_SPECIAL (_rl_tty_chars.t_lnext);
+# endif /* VLNEXT && TERMIOS_TTY_DRIVER */
+
+# if defined (VWERASE) && defined (TERMIOS_TTY_DRIVER)
+ RESET_SPECIAL (_rl_tty_chars.t_werase);
+# endif /* VWERASE && TERMIOS_TTY_DRIVER */
+}
+
+#if defined (HANDLE_SIGNALS)
+
+#if defined (NEW_TTY_DRIVER) || defined (NO_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;
+ nosigstty.c_iflag &= ~IXON;
+
+ 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 ()
+{
+ int r;
+
+ if (tty_sigs_disabled == 0)
+ return 0;
+
+ r = _set_tty_settings (fileno (rl_instream), &sigstty);
+
+ if (r == 0)
+ tty_sigs_disabled = 0;
+
+ return r;
+}
+#endif /* !NEW_TTY_DRIVER */
+
+#endif /* HANDLE_SIGNALS */
case AND_AND:
case OR_OR:
case '&':
+ case WHILE:
case DO:
+ case UNTIL:
+ case IF:
case THEN:
+ case ELIF:
case ELSE:
case '{': /* } */
- case '(': /* ) */
+ case '(': /* )( */
+ case ')': /* only valid in case statement */
case BANG: /* ! time pipeline */
case TIME: /* time time pipeline */
case TIMEOPT: /* time -p time pipeline */
#endif
#if defined (READLINE)
+# include <readline/readline.h>
# include "bashline.h"
#endif
fflush (stdout); /* XXX */
fflush (stderr);
+#if defined (READLINE)
+ if (RL_ISSTATE (RL_STATE_TERMPREPPED) && rl_deprep_term_function)
+ (*rl_deprep_term_function) ();
+#endif
+
/* Do trap[0] if defined. Allow it to override the exit status
passed to us. */
if (signal_is_trapped (0))
--- /dev/null
+/* shell.c -- GNU's idea of the POSIX shell specification. */
+
+/* Copyright (C) 1987-2012 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Bash is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ Birthdate:
+ Sunday, January 10th, 1988.
+ Initial author: Brian Fox
+*/
+#define INSTALL_DEBUG_MODE
+
+#include "config.h"
+
+#include "bashtypes.h"
+#if !defined (_MINIX) && defined (HAVE_SYS_FILE_H)
+# include <sys/file.h>
+#endif
+#include "posixstat.h"
+#include "posixtime.h"
+#include "bashansi.h"
+#include <stdio.h>
+#include <signal.h>
+#include <errno.h>
+#include "filecntl.h"
+#include <pwd.h>
+
+#if defined (HAVE_UNISTD_H)
+# include <unistd.h>
+#endif
+
+#include "bashintl.h"
+
+#define NEED_SH_SETLINEBUF_DECL /* used in externs.h */
+
+#include "shell.h"
+#include "flags.h"
+#include "trap.h"
+#include "mailcheck.h"
+#include "builtins.h"
+#include "builtins/common.h"
+
+#if defined (JOB_CONTROL)
+#include "jobs.h"
+#endif /* JOB_CONTROL */
+
+#include "input.h"
+#include "execute_cmd.h"
+#include "findcmd.h"
+
+#if defined (USING_BASH_MALLOC) && defined (DEBUG) && !defined (DISABLE_MALLOC_WRAPPERS)
+# include <malloc/shmalloc.h>
+#endif
+
+#if defined (HISTORY)
+# include "bashhist.h"
+# include <readline/history.h>
+#endif
+
+#if defined (READLINE)
+# include <readline/readline.h>
+# include "bashline.h"
+#endif
+
+#include <tilde/tilde.h>
+#include <glob/strmatch.h>
+
+#if defined (__OPENNT)
+# include <opennt/opennt.h>
+#endif
+
+#if !defined (HAVE_GETPW_DECLS)
+extern struct passwd *getpwuid ();
+#endif /* !HAVE_GETPW_DECLS */
+
+#if !defined (errno)
+extern int errno;
+#endif
+
+#if defined (NO_MAIN_ENV_ARG)
+extern char **environ; /* used if no third argument to main() */
+#endif
+
+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;
+extern int expand_aliases;
+extern int array_needs_making;
+extern int gnu_error_format;
+extern char *primary_prompt, *secondary_prompt;
+extern char *this_command_name;
+
+/* Non-zero means that this shell has already been run; i.e. you should
+ call shell_reinitialize () if you need to start afresh. */
+int shell_initialized = 0;
+
+COMMAND *global_command = (COMMAND *)NULL;
+
+/* Information about the current user. */
+struct user_info current_user =
+{
+ (uid_t)-1, (uid_t)-1, (gid_t)-1, (gid_t)-1,
+ (char *)NULL, (char *)NULL, (char *)NULL
+};
+
+/* The current host's name. */
+char *current_host_name = (char *)NULL;
+
+/* Non-zero means that this shell is a login shell.
+ Specifically:
+ 0 = not login shell.
+ 1 = login shell from getty (or equivalent fake out)
+ -1 = login shell from "--login" (or -l) flag.
+ -2 = both from getty, and from flag.
+ */
+int login_shell = 0;
+
+/* Non-zero means that at this moment, the shell is interactive. In
+ general, this means that the shell is at this moment reading input
+ from the keyboard. */
+int interactive = 0;
+
+/* Non-zero means that the shell was started as an interactive shell. */
+int interactive_shell = 0;
+
+/* Non-zero means to send a SIGHUP to all jobs when an interactive login
+ shell exits. */
+int hup_on_exit = 0;
+
+/* Non-zero means to list status of running and stopped jobs at shell exit */
+int check_jobs_at_exit = 0;
+
+/* Non-zero means to change to a directory name supplied as a command name */
+int autocd = 0;
+
+/* Tells what state the shell was in when it started:
+ 0 = non-interactive shell script
+ 1 = interactive
+ 2 = -c command
+ 3 = wordexp evaluation
+ This is a superset of the information provided by interactive_shell.
+*/
+int startup_state = 0;
+
+/* Special debugging helper. */
+int debugging_login_shell = 0;
+
+/* The environment that the shell passes to other commands. */
+char **shell_environment;
+
+/* Non-zero when we are executing a top-level command. */
+int executing = 0;
+
+/* The number of commands executed so far. */
+int current_command_number = 1;
+
+/* Non-zero is the recursion depth for commands. */
+int indirection_level = 0;
+
+/* The name of this shell, as taken from argv[0]. */
+char *shell_name = (char *)NULL;
+
+/* time in seconds when the shell was started */
+time_t shell_start_time;
+
+/* Are we running in an emacs shell window? */
+int running_under_emacs;
+
+/* Do we have /dev/fd? */
+#ifdef HAVE_DEV_FD
+int have_devfd = HAVE_DEV_FD;
+#else
+int have_devfd = 0;
+#endif
+
+/* The name of the .(shell)rc file. */
+static char *bashrc_file = DEFAULT_BASHRC;
+
+/* Non-zero means to act more like the Bourne shell on startup. */
+static int act_like_sh;
+
+/* Non-zero if this shell is being run by `su'. */
+static int su_shell;
+
+/* Non-zero if we have already expanded and sourced $ENV. */
+static int sourced_env;
+
+/* Is this shell running setuid? */
+static int running_setuid;
+
+/* Values for the long-winded argument names. */
+static int debugging; /* Do debugging things. */
+static int no_rc; /* Don't execute ~/.bashrc */
+static int no_profile; /* Don't execute .profile */
+static int do_version; /* Display interesting version info. */
+static int make_login_shell; /* Make this shell be a `-bash' shell. */
+static int want_initial_help; /* --help option */
+
+int debugging_mode = 0; /* In debugging mode with --debugger */
+#if defined (READLINE)
+int no_line_editing = 0; /* non-zero -> don't do fancy line editing. */
+#else
+int no_line_editing = 1; /* can't have line editing without readline */
+#endif
+int dump_translatable_strings; /* Dump strings in $"...", don't execute. */
+int dump_po_strings; /* Dump strings in $"..." in po format */
+int wordexp_only = 0; /* Do word expansion only */
+int protected_mode = 0; /* No command substitution with --wordexp */
+
+#if defined (STRICT_POSIX)
+int posixly_correct = 1; /* Non-zero means posix.2 superset. */
+#else
+int posixly_correct = 0; /* Non-zero means posix.2 superset. */
+#endif
+
+/* Some long-winded argument names. These are obviously new. */
+#define Int 1
+#define Charp 2
+static const struct {
+ const char *name;
+ int type;
+ int *int_value;
+ char **char_value;
+} long_args[] = {
+ { "debug", Int, &debugging, (char **)0x0 },
+#if defined (DEBUGGER)
+ { "debugger", Int, &debugging_mode, (char **)0x0 },
+#endif
+ { "dump-po-strings", Int, &dump_po_strings, (char **)0x0 },
+ { "dump-strings", Int, &dump_translatable_strings, (char **)0x0 },
+ { "help", Int, &want_initial_help, (char **)0x0 },
+ { "init-file", Charp, (int *)0x0, &bashrc_file },
+ { "login", Int, &make_login_shell, (char **)0x0 },
+ { "noediting", Int, &no_line_editing, (char **)0x0 },
+ { "noprofile", Int, &no_profile, (char **)0x0 },
+ { "norc", Int, &no_rc, (char **)0x0 },
+ { "posix", Int, &posixly_correct, (char **)0x0 },
+#if defined (WORDEXP_OPTION)
+ { "protected", Int, &protected_mode, (char **)0x0 },
+#endif
+ { "rcfile", Charp, (int *)0x0, &bashrc_file },
+#if defined (RESTRICTED_SHELL)
+ { "restricted", Int, &restricted, (char **)0x0 },
+#endif
+ { "verbose", Int, &echo_input_at_read, (char **)0x0 },
+ { "version", Int, &do_version, (char **)0x0 },
+#if defined (WORDEXP_OPTION)
+ { "wordexp", Int, &wordexp_only, (char **)0x0 },
+#endif
+ { (char *)0x0, Int, (int *)0x0, (char **)0x0 }
+};
+
+/* These are extern so execute_simple_command can set them, and then
+ longjmp back to main to execute a shell script, instead of calling
+ main () again and resulting in indefinite, possibly fatal, stack
+ growth. */
+procenv_t subshell_top_level;
+int subshell_argc;
+char **subshell_argv;
+char **subshell_envp;
+
+char *exec_argv0;
+
+#if defined (BUFFERED_INPUT)
+/* The file descriptor from which the shell is reading input. */
+int default_buffered_input = -1;
+#endif
+
+/* 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 */
+
+/* This variable is not static so it can be bound to $BASH_EXECUTION_STRING */
+char *command_execution_string; /* argument to -c option */
+
+int malloc_trace_at_exit = 0;
+
+static int shell_reinitialized = 0;
+
+static FILE *default_input;
+
+static STRING_INT_ALIST *shopt_alist;
+static int shopt_ind = 0, shopt_len = 0;
+
+static int parse_long_options __P((char **, int, int));
+static int parse_shell_options __P((char **, int, int));
+static int bind_args __P((char **, int, int, int));
+
+static void start_debugger __P((void));
+
+static void add_shopt_to_alist __P((char *, int));
+static void run_shopt_alist __P((void));
+
+static void execute_env_file __P((char *));
+static void run_startup_files __P((void));
+static int open_shell_script __P((char *));
+static void set_bash_input __P((void));
+static int run_one_command __P((char *));
+#if defined (WORDEXP_OPTION)
+static int run_wordexp __P((char *));
+#endif
+
+static int uidget __P((void));
+
+static void init_interactive __P((void));
+static void init_noninteractive __P((void));
+static void init_interactive_script __P((void));
+
+static void set_shell_name __P((char *));
+static void shell_initialize __P((void));
+static void shell_reinitialize __P((void));
+
+static void show_shell_usage __P((FILE *, int));
+
+#ifdef __CYGWIN__
+static void
+_cygwin32_check_tmp ()
+{
+ struct stat sb;
+
+ if (stat ("/tmp", &sb) < 0)
+ internal_warning (_("could not find /tmp, please create!"));
+ else
+ {
+ if (S_ISDIR (sb.st_mode) == 0)
+ internal_warning (_("/tmp must be a valid directory name"));
+ }
+}
+#endif /* __CYGWIN__ */
+
+#if defined (NO_MAIN_ENV_ARG)
+/* systems without third argument to main() */
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+#else /* !NO_MAIN_ENV_ARG */
+int
+main (argc, argv, env)
+ int argc;
+ char **argv, **env;
+#endif /* !NO_MAIN_ENV_ARG */
+{
+ register int i;
+ int code, old_errexit_flag;
+#if defined (RESTRICTED_SHELL)
+ int saverst;
+#endif
+ volatile int locally_skip_execution;
+ volatile int arg_index, top_level_arg_index;
+#ifdef __OPENNT
+ char **env;
+
+ env = environ;
+#endif /* __OPENNT */
+
+ USE_VAR(argc);
+ USE_VAR(argv);
+ USE_VAR(env);
+ USE_VAR(code);
+ USE_VAR(old_errexit_flag);
+#if defined (RESTRICTED_SHELL)
+ USE_VAR(saverst);
+#endif
+
+ /* Catch early SIGINTs. */
+ code = setjmp_nosigs (top_level);
+ if (code)
+ exit (2);
+
+ xtrace_init ();
+
+#if defined (USING_BASH_MALLOC) && defined (DEBUG) && !defined (DISABLE_MALLOC_WRAPPERS)
+# if 1
+ malloc_set_register (1);
+# endif
+#endif
+
+ check_dev_tty ();
+
+#ifdef __CYGWIN__
+ _cygwin32_check_tmp ();
+#endif /* __CYGWIN__ */
+
+ /* Wait forever if we are debugging a login shell. */
+ while (debugging_login_shell) sleep (3);
+
+ set_default_locale ();
+
+ running_setuid = uidget ();
+
+ if (getenv ("POSIXLY_CORRECT") || getenv ("POSIX_PEDANTIC"))
+ posixly_correct = 1;
+
+#if defined (USE_GNU_MALLOC_LIBRARY)
+ mcheck (programming_error, (void (*) ())0);
+#endif /* USE_GNU_MALLOC_LIBRARY */
+
+ if (setjmp (subshell_top_level))
+ {
+ argc = subshell_argc;
+ argv = subshell_argv;
+ env = subshell_envp;
+ sourced_env = 0;
+ }
+
+ shell_reinitialized = 0;
+
+ /* Initialize `local' variables for all `invocations' of main (). */
+ arg_index = 1;
+ if (arg_index > argc)
+ arg_index = argc;
+ command_execution_string = (char *)NULL;
+ want_pending_command = locally_skip_execution = read_from_stdin = 0;
+ default_input = stdin;
+#if defined (BUFFERED_INPUT)
+ default_buffered_input = -1;
+#endif
+
+ /* Fix for the `infinite process creation' bug when running shell scripts
+ from startup files on System V. */
+ login_shell = make_login_shell = 0;
+
+ /* If this shell has already been run, then reinitialize it to a
+ vanilla state. */
+ if (shell_initialized || shell_name)
+ {
+ /* Make sure that we do not infinitely recurse as a login shell. */
+ if (*shell_name == '-')
+ shell_name++;
+
+ shell_reinitialize ();
+ if (setjmp_nosigs (top_level))
+ exit (2);
+ }
+
+ shell_environment = env;
+ set_shell_name (argv[0]);
+ shell_start_time = NOW; /* NOW now defined in general.h */
+
+ /* Parse argument flags from the input line. */
+
+ /* Find full word arguments first. */
+ arg_index = parse_long_options (argv, arg_index, argc);
+
+ if (want_initial_help)
+ {
+ show_shell_usage (stdout, 1);
+ exit (EXECUTION_SUCCESS);
+ }
+
+ if (do_version)
+ {
+ show_shell_version (1);
+ exit (EXECUTION_SUCCESS);
+ }
+
+ /* All done with full word options; do standard shell option parsing.*/
+ this_command_name = shell_name; /* for error reporting */
+ arg_index = parse_shell_options (argv, arg_index, argc);
+
+ /* If user supplied the "--login" (or -l) flag, then set and invert
+ LOGIN_SHELL. */
+ if (make_login_shell)
+ {
+ login_shell++;
+ login_shell = -login_shell;
+ }
+
+ set_login_shell ("login_shell", login_shell != 0);
+
+ if (dump_po_strings)
+ dump_translatable_strings = 1;
+
+ if (dump_translatable_strings)
+ read_but_dont_execute = 1;
+
+ if (running_setuid && privileged_mode == 0)
+ disable_priv_mode ();
+
+ /* Need to get the argument to a -c option processed in the
+ above loop. The next arg is a command to execute, and the
+ following args are $0...$n respectively. */
+ if (want_pending_command)
+ {
+ command_execution_string = argv[arg_index];
+ if (command_execution_string == 0)
+ {
+ report_error (_("%s: option requires an argument"), "-c");
+ exit (EX_BADUSAGE);
+ }
+ arg_index++;
+ }
+ this_command_name = (char *)NULL;
+
+ cmd_init(); /* initialize the command object caches */
+
+ /* First, let the outside world know about our interactive status.
+ A shell is interactive if the `-i' flag was given, or if all of
+ the following conditions are met:
+ no -c command
+ no arguments remaining or the -s flag given
+ standard input is a terminal
+ standard error is a terminal
+ Refer to Posix.2, the description of the `sh' utility. */
+
+ if (forced_interactive || /* -i flag */
+ (!command_execution_string && /* No -c command and ... */
+ wordexp_only == 0 && /* No --wordexp and ... */
+ ((arg_index == argc) || /* no remaining args or... */
+ read_from_stdin) && /* -s flag with args, and */
+ isatty (fileno (stdin)) && /* Input is a terminal and */
+ isatty (fileno (stderr)))) /* error output is a terminal. */
+ init_interactive ();
+ else
+ init_noninteractive ();
+
+ /*
+ * Some systems have the bad habit of starting login shells with lots of open
+ * file descriptors. For instance, most systems that have picked up the
+ * pre-4.0 Sun YP code leave a file descriptor open each time you call one
+ * of the getpw* functions, and it's set to be open across execs. That
+ * means one for login, one for xterm, one for shelltool, etc. There are
+ * also systems that open persistent FDs to other agents or files as part
+ * of process startup; these need to be set to be close-on-exec.
+ */
+ if (login_shell && interactive_shell)
+ {
+ for (i = 3; i < 20; i++)
+ SET_CLOSE_ON_EXEC (i);
+ }
+
+ /* If we're in a strict Posix.2 mode, turn on interactive comments,
+ alias expansion in non-interactive shells, and other Posix.2 things. */
+ if (posixly_correct)
+ {
+ bind_variable ("POSIXLY_CORRECT", "y", 0);
+ sv_strict_posix ("POSIXLY_CORRECT");
+ }
+
+ /* Now we run the shopt_alist and process the options. */
+ if (shopt_alist)
+ run_shopt_alist ();
+
+ /* From here on in, the shell must be a normal functioning shell.
+ Variables from the environment are expected to be set, etc. */
+ shell_initialize ();
+
+ set_default_lang ();
+ set_default_locale_vars ();
+
+ /*
+ * M-x term -> TERM=eterm EMACS=22.1 (term:0.96) (eterm)
+ * M-x shell -> TERM=dumb EMACS=t (no line editing)
+ * M-x terminal -> TERM=emacs-em7955 EMACS= (line editing)
+ */
+ if (interactive_shell)
+ {
+ char *term, *emacs;
+
+ term = get_string_value ("TERM");
+ emacs = get_string_value ("EMACS");
+
+ /* Not sure any emacs terminal emulator sets TERM=emacs any more */
+ no_line_editing |= term && (STREQ (term, "emacs"));
+ no_line_editing |= emacs && emacs[0] == 't' && emacs[1] == '\0' && STREQ (term, "dumb");
+
+ /* running_under_emacs == 2 for `eterm' */
+ running_under_emacs = (emacs != 0) || (term && STREQN (term, "emacs", 5));
+ running_under_emacs += term && STREQN (term, "eterm", 5) && emacs && strstr (emacs, "term");
+
+ if (running_under_emacs)
+ gnu_error_format = 1;
+ }
+
+ top_level_arg_index = arg_index;
+ old_errexit_flag = exit_immediately_on_error;
+
+ /* Give this shell a place to longjmp to before executing the
+ startup files. This allows users to press C-c to abort the
+ lengthy startup. */
+ code = setjmp (top_level);
+ if (code)
+ {
+ if (code == EXITPROG || code == ERREXIT)
+ exit_shell (last_command_exit_value);
+ else
+ {
+#if defined (JOB_CONTROL)
+ /* Reset job control, since run_startup_files turned it off. */
+ set_job_control (interactive_shell);
+#endif
+ /* Reset value of `set -e', since it's turned off before running
+ the startup files. */
+ exit_immediately_on_error += old_errexit_flag;
+ locally_skip_execution++;
+ }
+ }
+
+ arg_index = top_level_arg_index;
+
+ /* Execute the start-up scripts. */
+
+ if (interactive_shell == 0)
+ {
+ unbind_variable ("PS1");
+ unbind_variable ("PS2");
+ interactive = 0;
+#if 0
+ /* This has already been done by init_noninteractive */
+ expand_aliases = posixly_correct;
+#endif
+ }
+ else
+ {
+ change_flag ('i', FLAG_ON);
+ interactive = 1;
+ }
+
+#if defined (RESTRICTED_SHELL)
+ /* Set restricted_shell based on whether the basename of $0 indicates that
+ the shell should be restricted or if the `-r' option was supplied at
+ startup. */
+ restricted_shell = shell_is_restricted (shell_name);
+
+ /* If the `-r' option is supplied at invocation, make sure that the shell
+ is not in restricted mode when running the startup files. */
+ saverst = restricted;
+ restricted = 0;
+#endif
+
+ /* The startup files are run with `set -e' temporarily disabled. */
+ if (locally_skip_execution == 0 && running_setuid == 0)
+ {
+ old_errexit_flag = exit_immediately_on_error;
+ exit_immediately_on_error = 0;
+
+ run_startup_files ();
+ exit_immediately_on_error += old_errexit_flag;
+ }
+
+ /* If we are invoked as `sh', turn on Posix mode. */
+ if (act_like_sh)
+ {
+ bind_variable ("POSIXLY_CORRECT", "y", 0);
+ sv_strict_posix ("POSIXLY_CORRECT");
+ }
+
+#if defined (RESTRICTED_SHELL)
+ /* Turn on the restrictions after executing the startup files. This
+ means that `bash -r' or `set -r' invoked from a startup file will
+ turn on the restrictions after the startup files are executed. */
+ restricted = saverst || restricted;
+ if (shell_reinitialized == 0)
+ maybe_make_restricted (shell_name);
+#endif /* RESTRICTED_SHELL */
+
+#if defined (WORDEXP_OPTION)
+ if (wordexp_only)
+ {
+ startup_state = 3;
+ last_command_exit_value = run_wordexp (argv[arg_index]);
+ exit_shell (last_command_exit_value);
+ }
+#endif
+
+ if (command_execution_string)
+ {
+ arg_index = bind_args (argv, arg_index, argc, 0);
+ startup_state = 2;
+
+ if (debugging_mode)
+ start_debugger ();
+
+#if defined (ONESHOT)
+ executing = 1;
+ run_one_command (command_execution_string);
+ exit_shell (last_command_exit_value);
+#else /* ONESHOT */
+ with_input_from_string (command_execution_string, "-c");
+ goto read_and_execute;
+#endif /* !ONESHOT */
+ }
+
+ /* Get possible input filename and set up default_buffered_input or
+ default_input as appropriate. */
+ if (arg_index != argc && read_from_stdin == 0)
+ {
+ open_shell_script (argv[arg_index]);
+ arg_index++;
+ }
+ else if (interactive == 0)
+ /* In this mode, bash is reading a script from stdin, which is a
+ pipe or redirected file. */
+#if defined (BUFFERED_INPUT)
+ default_buffered_input = fileno (stdin); /* == 0 */
+#else
+ setbuf (default_input, (char *)NULL);
+#endif /* !BUFFERED_INPUT */
+
+ set_bash_input ();
+
+ /* Bind remaining args to $1 ... $n */
+ arg_index = bind_args (argv, arg_index, argc, 1);
+
+ if (debugging_mode && locally_skip_execution == 0 && running_setuid == 0 && dollar_vars[1])
+ start_debugger ();
+
+ /* Do the things that should be done only for interactive shells. */
+ if (interactive_shell)
+ {
+ /* Set up for checking for presence of mail. */
+ reset_mail_timer ();
+ init_mail_dates ();
+
+#if defined (HISTORY)
+ /* Initialize the interactive history stuff. */
+ bash_initialize_history ();
+ /* Don't load the history from the history file if we've already
+ saved some lines in this session (e.g., by putting `history -s xx'
+ into one of the startup files). */
+ if (shell_initialized == 0 && history_lines_this_session == 0)
+ load_history ();
+#endif /* HISTORY */
+
+ /* Initialize terminal state for interactive shells after the
+ .bash_profile and .bashrc are interpreted. */
+ get_tty_state ();
+ }
+
+#if !defined (ONESHOT)
+ read_and_execute:
+#endif /* !ONESHOT */
+
+ shell_initialized = 1;
+
+ /* Read commands until exit condition. */
+ reader_loop ();
+ exit_shell (last_command_exit_value);
+}
+
+static int
+parse_long_options (argv, arg_start, arg_end)
+ char **argv;
+ int arg_start, arg_end;
+{
+ int arg_index, longarg, i;
+ char *arg_string;
+
+ arg_index = arg_start;
+ while ((arg_index != arg_end) && (arg_string = argv[arg_index]) &&
+ (*arg_string == '-'))
+ {
+ longarg = 0;
+
+ /* Make --login equivalent to -login. */
+ if (arg_string[1] == '-' && arg_string[2])
+ {
+ longarg = 1;
+ arg_string++;
+ }
+
+ for (i = 0; long_args[i].name; i++)
+ {
+ if (STREQ (arg_string + 1, long_args[i].name))
+ {
+ if (long_args[i].type == Int)
+ *long_args[i].int_value = 1;
+ else if (argv[++arg_index] == 0)
+ {
+ report_error (_("%s: option requires an argument"), long_args[i].name);
+ exit (EX_BADUSAGE);
+ }
+ else
+ *long_args[i].char_value = argv[arg_index];
+
+ break;
+ }
+ }
+ if (long_args[i].name == 0)
+ {
+ if (longarg)
+ {
+ report_error (_("%s: invalid option"), argv[arg_index]);
+ show_shell_usage (stderr, 0);
+ exit (EX_BADUSAGE);
+ }
+ break; /* No such argument. Maybe flag arg. */
+ }
+
+ arg_index++;
+ }
+
+ return (arg_index);
+}
+
+static int
+parse_shell_options (argv, arg_start, arg_end)
+ char **argv;
+ int arg_start, arg_end;
+{
+ int arg_index;
+ int arg_character, on_or_off, next_arg, i;
+ char *o_option, *arg_string;
+
+ arg_index = arg_start;
+ while (arg_index != arg_end && (arg_string = argv[arg_index]) &&
+ (*arg_string == '-' || *arg_string == '+'))
+ {
+ /* There are flag arguments, so parse them. */
+ next_arg = arg_index + 1;
+
+ /* A single `-' signals the end of options. From the 4.3 BSD sh.
+ An option `--' means the same thing; this is the standard
+ getopt(3) meaning. */
+ if (arg_string[0] == '-' &&
+ (arg_string[1] == '\0' ||
+ (arg_string[1] == '-' && arg_string[2] == '\0')))
+ return (next_arg);
+
+ i = 1;
+ on_or_off = arg_string[0];
+ while (arg_character = arg_string[i++])
+ {
+ switch (arg_character)
+ {
+ case 'c':
+ want_pending_command = 1;
+ break;
+
+ case 'l':
+ make_login_shell = 1;
+ break;
+
+ case 's':
+ read_from_stdin = 1;
+ break;
+
+ case 'o':
+ o_option = argv[next_arg];
+ if (o_option == 0)
+ {
+ list_minus_o_opts (-1, (on_or_off == '-') ? 0 : 1);
+ break;
+ }
+ if (set_minus_o_option (on_or_off, o_option) != EXECUTION_SUCCESS)
+ exit (EX_BADUSAGE);
+ next_arg++;
+ break;
+
+ case 'O':
+ /* Since some of these can be overridden by the normal
+ interactive/non-interactive shell initialization or
+ initializing posix mode, we save the options and process
+ them after initialization. */
+ o_option = argv[next_arg];
+ if (o_option == 0)
+ {
+ shopt_listopt (o_option, (on_or_off == '-') ? 0 : 1);
+ break;
+ }
+ add_shopt_to_alist (o_option, on_or_off);
+ next_arg++;
+ break;
+
+ case 'D':
+ dump_translatable_strings = 1;
+ break;
+
+ default:
+ if (change_flag (arg_character, on_or_off) == FLAG_ERROR)
+ {
+ report_error (_("%c%c: invalid option"), on_or_off, arg_character);
+ show_shell_usage (stderr, 0);
+ exit (EX_BADUSAGE);
+ }
+ }
+ }
+ /* Can't do just a simple increment anymore -- what about
+ "bash -abouo emacs ignoreeof -hP"? */
+ arg_index = next_arg;
+ }
+
+ return (arg_index);
+}
+
+/* Exit the shell with status S. */
+void
+exit_shell (s)
+ int s;
+{
+ fflush (stdout); /* XXX */
+ fflush (stderr);
+
+#if defined (READLINE)
+ if (RL_ISSTATE (RL_STATE_TERMPREPPED))
+{
+itrace("exit_shell: rl_term_prepped: calling rl_deprep_term_function");
+if (rl_deprep_term_function)
+ (*rl_deprep_term_function) ();
+}
+#endif
+
+ /* Do trap[0] if defined. Allow it to override the exit status
+ passed to us. */
+ if (signal_is_trapped (0))
+ s = run_exit_trap ();
+
+#if defined (PROCESS_SUBSTITUTION)
+ unlink_fifo_list ();
+#endif /* PROCESS_SUBSTITUTION */
+
+#if defined (HISTORY)
+ if (remember_on_history)
+ maybe_save_shell_history ();
+#endif /* HISTORY */
+
+#if defined (COPROCESS_SUPPORT)
+ coproc_flush ();
+#endif
+
+#if defined (JOB_CONTROL)
+ /* If the user has run `shopt -s huponexit', hangup all jobs when we exit
+ an interactive login shell. ksh does this unconditionally. */
+ if (interactive_shell && login_shell && hup_on_exit)
+ hangup_all_jobs ();
+
+ /* If this shell is interactive, or job control is active, terminate all
+ stopped jobs and restore the original terminal process group. Don't do
+ this if we're in a subshell and calling exit_shell after, for example,
+ a failed word expansion. We want to do this even if the shell is not
+ interactive because we set the terminal's process group when job control
+ is enabled regardless of the interactive status. */
+ if (subshell_environment == 0)
+ end_job_control ();
+#endif /* JOB_CONTROL */
+
+ /* Always return the exit status of the last command to our parent. */
+ sh_exit (s);
+}
+
+/* A wrapper for exit that (optionally) can do other things, like malloc
+ statistics tracing. */
+void
+sh_exit (s)
+ int s;
+{
+#if defined (MALLOC_DEBUG) && defined (USING_BASH_MALLOC)
+ if (malloc_trace_at_exit)
+ trace_malloc_stats (get_name_for_error (), (char *)NULL);
+#endif
+
+ exit (s);
+}
+
+/* Exit a subshell, which includes calling the exit trap. We don't want to
+ do any more cleanup, since a subshell is created as an exact copy of its
+ parent. */
+void
+subshell_exit (s)
+ int s;
+{
+ fflush (stdout);
+ fflush (stderr);
+
+ /* Do trap[0] if defined. Allow it to override the exit status
+ passed to us. */
+ if (signal_is_trapped (0))
+ s = run_exit_trap ();
+
+ sh_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
+ for interactive shells only. (section 4.56.5.3) */
+
+/* Execute ~/.bashrc for most shells. Never execute it if
+ ACT_LIKE_SH is set, or if NO_RC is set.
+
+ If the executable file "/usr/gnu/src/bash/foo" contains:
+
+ #!/usr/gnu/bin/bash
+ echo hello
+
+ then:
+
+ COMMAND EXECUTE BASHRC
+ --------------------------------
+ bash -c foo NO
+ bash foo NO
+ foo NO
+ rsh machine ls YES (for rsh, which calls `bash -c')
+ rsh machine foo YES (for shell started by rsh) NO (for foo!)
+ echo ls | bash NO
+ login NO
+ bash YES
+*/
+
+static void
+execute_env_file (env_file)
+ char *env_file;
+{
+ char *fn;
+
+ if (env_file && *env_file)
+ {
+ fn = expand_string_unsplit_to_string (env_file, Q_DOUBLE_QUOTES);
+ if (fn && *fn)
+ maybe_execute_file (fn, 1);
+ FREE (fn);
+ }
+}
+
+static void
+run_startup_files ()
+{
+#if defined (JOB_CONTROL)
+ int old_job_control;
+#endif
+ int sourced_login, run_by_ssh;
+
+ /* get the rshd/sshd case out of the way first. */
+ if (interactive_shell == 0 && no_rc == 0 && login_shell == 0 &&
+ act_like_sh == 0 && command_execution_string)
+ {
+#ifdef SSH_SOURCE_BASHRC
+ run_by_ssh = (find_variable ("SSH_CLIENT") != (SHELL_VAR *)0) ||
+ (find_variable ("SSH2_CLIENT") != (SHELL_VAR *)0);
+#else
+ run_by_ssh = 0;
+#endif
+
+ /* If we were run by sshd or we think we were run by rshd, execute
+ ~/.bashrc if we are a top-level shell. */
+ if ((run_by_ssh || isnetconn (fileno (stdin))) && shell_level < 2)
+ {
+#ifdef SYS_BASHRC
+# if defined (__OPENNT)
+ maybe_execute_file (_prefixInstallPath(SYS_BASHRC, NULL, 0), 1);
+# else
+ maybe_execute_file (SYS_BASHRC, 1);
+# endif
+#endif
+ maybe_execute_file (bashrc_file, 1);
+ return;
+ }
+ }
+
+#if defined (JOB_CONTROL)
+ /* Startup files should be run without job control enabled. */
+ old_job_control = interactive_shell ? set_job_control (0) : 0;
+#endif
+
+ sourced_login = 0;
+
+ /* A shell begun with the --login (or -l) 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++;
+
+ /* Execute /etc/profile and one of the personal login shell
+ initialization files. */
+ if (no_profile == 0)
+ {
+ maybe_execute_file (SYS_PROFILE, 1);
+
+ if (act_like_sh) /* sh */
+ maybe_execute_file ("~/.profile", 1);
+ else if ((maybe_execute_file ("~/.bash_profile", 1) == 0) &&
+ (maybe_execute_file ("~/.bash_login", 1) == 0)) /* bash */
+ maybe_execute_file ("~/.profile", 1);
+ }
+
+ sourced_login = 1;
+ }
+
+ /* A non-interactive shell not named `sh' and not in posix mode reads and
+ executes commands from $BASH_ENV. If `su' starts a shell with `-c cmd'
+ and `-su' as the name of the shell, we want to read the startup files.
+ No other non-interactive shells read any startup files. */
+ if (interactive_shell == 0 && !(su_shell && login_shell))
+ {
+ if (posixly_correct == 0 && act_like_sh == 0 && privileged_mode == 0 &&
+ sourced_env++ == 0)
+ execute_env_file (get_string_value ("BASH_ENV"));
+ return;
+ }
+
+ /* Interactive shell or `-su' shell. */
+ if (posixly_correct == 0) /* bash, sh */
+ {
+ if (login_shell && sourced_login++ == 0)
+ {
+ /* We don't execute .bashrc for login shells. */
+ no_rc++;
+
+ /* Execute /etc/profile and one of the personal login shell
+ initialization files. */
+ if (no_profile == 0)
+ {
+ maybe_execute_file (SYS_PROFILE, 1);
+
+ if (act_like_sh) /* sh */
+ maybe_execute_file ("~/.profile", 1);
+ else if ((maybe_execute_file ("~/.bash_profile", 1) == 0) &&
+ (maybe_execute_file ("~/.bash_login", 1) == 0)) /* bash */
+ maybe_execute_file ("~/.profile", 1);
+ }
+ }
+
+ /* bash */
+ if (act_like_sh == 0 && no_rc == 0)
+ {
+#ifdef SYS_BASHRC
+# if defined (__OPENNT)
+ maybe_execute_file (_prefixInstallPath(SYS_BASHRC, NULL, 0), 1);
+# else
+ maybe_execute_file (SYS_BASHRC, 1);
+# endif
+#endif
+ maybe_execute_file (bashrc_file, 1);
+ }
+ /* sh */
+ else if (act_like_sh && privileged_mode == 0 && sourced_env++ == 0)
+ execute_env_file (get_string_value ("ENV"));
+ }
+ else /* bash --posix, sh --posix */
+ {
+ /* bash and sh */
+ if (interactive_shell && privileged_mode == 0 && sourced_env++ == 0)
+ execute_env_file (get_string_value ("ENV"));
+ }
+
+#if defined (JOB_CONTROL)
+ set_job_control (old_job_control);
+#endif
+}
+
+#if defined (RESTRICTED_SHELL)
+/* Return 1 if the shell should be a restricted one based on NAME or the
+ value of `restricted'. Don't actually do anything, just return a
+ boolean value. */
+int
+shell_is_restricted (name)
+ char *name;
+{
+ char *temp;
+
+ if (restricted)
+ return 1;
+ temp = base_pathname (name);
+ if (*temp == '-')
+ temp++;
+ return (STREQ (temp, RESTRICTED_SHELL_NAME));
+}
+
+/* Perhaps make this shell a `restricted' one, based on NAME. If the
+ basename of NAME is "rbash", then this shell is restricted. The
+ name of the restricted shell is a configurable option, see config.h.
+ In a restricted shell, PATH, SHELL, ENV, and BASH_ENV are read-only
+ and non-unsettable.
+ Do this also if `restricted' is already set to 1; maybe the shell was
+ started with -r. */
+int
+maybe_make_restricted (name)
+ char *name;
+{
+ char *temp;
+
+ temp = base_pathname (name);
+ if (*temp == '-')
+ temp++;
+ if (restricted || (STREQ (temp, RESTRICTED_SHELL_NAME)))
+ {
+ set_var_read_only ("PATH");
+ set_var_read_only ("SHELL");
+ set_var_read_only ("ENV");
+ set_var_read_only ("BASH_ENV");
+ restricted = 1;
+ }
+ return (restricted);
+}
+#endif /* RESTRICTED_SHELL */
+
+/* Fetch the current set of uids and gids and return 1 if we're running
+ setuid or setgid. */
+static int
+uidget ()
+{
+ uid_t u;
+
+ u = getuid ();
+ if (current_user.uid != u)
+ {
+ FREE (current_user.user_name);
+ FREE (current_user.shell);
+ FREE (current_user.home_dir);
+ current_user.user_name = current_user.shell = current_user.home_dir = (char *)NULL;
+ }
+ current_user.uid = u;
+ current_user.gid = getgid ();
+ current_user.euid = geteuid ();
+ current_user.egid = getegid ();
+
+ /* See whether or not we are running setuid or setgid. */
+ return (current_user.uid != current_user.euid) ||
+ (current_user.gid != current_user.egid);
+}
+
+void
+disable_priv_mode ()
+{
+ int e;
+
+ if (setuid (current_user.uid) < 0)
+ {
+ e = errno;
+ sys_error (_("cannot set uid to %d: effective uid %d"), current_user.uid, current_user.euid);
+#if defined (EXIT_ON_SETUID_FAILURE)
+ if (e == EAGAIN)
+ exit (e);
+#endif
+ }
+ if (setgid (current_user.gid) < 0)
+ sys_error (_("cannot set gid to %d: effective gid %d"), current_user.gid, current_user.egid);
+
+ current_user.euid = current_user.uid;
+ current_user.egid = current_user.gid;
+}
+
+#if defined (WORDEXP_OPTION)
+static int
+run_wordexp (words)
+ char *words;
+{
+ int code, nw, nb;
+ WORD_LIST *wl, *tl, *result;
+
+ code = setjmp_nosigs (top_level);
+
+ if (code != NOT_JUMPED)
+ {
+ switch (code)
+ {
+ /* Some kind of throw to top_level has occurred. */
+ case FORCE_EOF:
+ return last_command_exit_value = 127;
+ case ERREXIT:
+ case EXITPROG:
+ return last_command_exit_value;
+ case DISCARD:
+ return last_command_exit_value = 1;
+ default:
+ command_error ("run_wordexp", CMDERR_BADJUMP, code, 0);
+ }
+ }
+
+ /* Run it through the parser to get a list of words and expand them */
+ if (words && *words)
+ {
+ with_input_from_string (words, "--wordexp");
+ if (parse_command () != 0)
+ return (126);
+ if (global_command == 0)
+ {
+ printf ("0\n0\n");
+ return (0);
+ }
+ if (global_command->type != cm_simple)
+ return (126);
+ wl = global_command->value.Simple->words;
+ if (protected_mode)
+ for (tl = wl; tl; tl = tl->next)
+ tl->word->flags |= W_NOCOMSUB|W_NOPROCSUB;
+ result = wl ? expand_words_no_vars (wl) : (WORD_LIST *)0;
+ }
+ else
+ result = (WORD_LIST *)0;
+
+ last_command_exit_value = 0;
+
+ if (result == 0)
+ {
+ printf ("0\n0\n");
+ return (0);
+ }
+
+ /* Count up the number of words and bytes, and print them. Don't count
+ the trailing NUL byte. */
+ for (nw = nb = 0, wl = result; wl; wl = wl->next)
+ {
+ nw++;
+ nb += strlen (wl->word->word);
+ }
+ printf ("%u\n%u\n", nw, nb);
+ /* Print each word on a separate line. This will have to be changed when
+ the interface to glibc is completed. */
+ for (wl = result; wl; wl = wl->next)
+ printf ("%s\n", wl->word->word);
+
+ return (0);
+}
+#endif
+
+#if defined (ONESHOT)
+/* Run one command, given as the argument to the -c option. Tell
+ parse_and_execute not to fork for a simple command. */
+static int
+run_one_command (command)
+ char *command;
+{
+ int code;
+
+ code = setjmp_nosigs (top_level);
+
+ if (code != NOT_JUMPED)
+ {
+#if defined (PROCESS_SUBSTITUTION)
+ unlink_fifo_list ();
+#endif /* PROCESS_SUBSTITUTION */
+ switch (code)
+ {
+ /* Some kind of throw to top_level has occurred. */
+ case FORCE_EOF:
+ return last_command_exit_value = 127;
+ case ERREXIT:
+ case EXITPROG:
+ return last_command_exit_value;
+ case DISCARD:
+ return last_command_exit_value = 1;
+ default:
+ command_error ("run_one_command", CMDERR_BADJUMP, code, 0);
+ }
+ }
+ return (parse_and_execute (savestring (command), "-c", SEVAL_NOHIST));
+}
+#endif /* ONESHOT */
+
+static int
+bind_args (argv, arg_start, arg_end, start_index)
+ char **argv;
+ int arg_start, arg_end, start_index;
+{
+ register int i;
+ WORD_LIST *args;
+
+ for (i = arg_start, args = (WORD_LIST *)NULL; i < arg_end; i++)
+ args = make_word_list (make_word (argv[i]), args);
+ if (args)
+ {
+ args = REVERSE_LIST (args, WORD_LIST *);
+ if (start_index == 0) /* bind to $0...$n for sh -c command */
+ {
+ /* Posix.2 4.56.3 says that the first argument after sh -c command
+ becomes $0, and the rest of the arguments become $1...$n */
+ shell_name = savestring (args->word->word);
+ FREE (dollar_vars[0]);
+ dollar_vars[0] = savestring (args->word->word);
+ remember_args (args->next, 1);
+ push_args (args->next); /* BASH_ARGV and BASH_ARGC */
+ }
+ else /* bind to $1...$n for shell script */
+ {
+ remember_args (args, 1);
+ push_args (args); /* BASH_ARGV and BASH_ARGC */
+ }
+
+ dispose_words (args);
+ }
+
+ return (i);
+}
+
+void
+unbind_args ()
+{
+ remember_args ((WORD_LIST *)NULL, 1);
+ pop_args (); /* Reset BASH_ARGV and BASH_ARGC */
+}
+
+static void
+start_debugger ()
+{
+#if defined (DEBUGGER) && defined (DEBUGGER_START_FILE)
+ int old_errexit;
+
+ old_errexit = exit_immediately_on_error;
+ exit_immediately_on_error = 0;
+
+ maybe_execute_file (DEBUGGER_START_FILE, 1);
+ function_trace_mode = 1;
+
+ exit_immediately_on_error += old_errexit;
+#endif
+}
+
+static int
+open_shell_script (script_name)
+ char *script_name;
+{
+ int fd, e, fd_is_tty;
+ char *filename, *path_filename, *t;
+ char sample[80];
+ int sample_len;
+ struct stat sb;
+#if defined (ARRAY_VARS)
+ SHELL_VAR *funcname_v, *bash_source_v, *bash_lineno_v;
+ ARRAY *funcname_a, *bash_source_a, *bash_lineno_a;
+#endif
+
+ filename = savestring (script_name);
+
+ fd = open (filename, O_RDONLY);
+ if ((fd < 0) && (errno == ENOENT) && (absolute_program (filename) == 0))
+ {
+ e = errno;
+ /* If it's not in the current directory, try looking through PATH
+ for it. */
+ path_filename = find_path_file (script_name);
+ if (path_filename)
+ {
+ free (filename);
+ filename = path_filename;
+ fd = open (filename, O_RDONLY);
+ }
+ else
+ errno = e;
+ }
+
+ if (fd < 0)
+ {
+ e = errno;
+ file_error (filename);
+ exit ((e == ENOENT) ? EX_NOTFOUND : EX_NOINPUT);
+ }
+
+ free (dollar_vars[0]);
+ dollar_vars[0] = exec_argv0 ? savestring (exec_argv0) : savestring (script_name);
+ if (exec_argv0)
+ {
+ free (exec_argv0);
+ exec_argv0 = (char *)NULL;
+ }
+
+#if defined (ARRAY_VARS)
+ GET_ARRAY_FROM_VAR ("FUNCNAME", funcname_v, funcname_a);
+ GET_ARRAY_FROM_VAR ("BASH_SOURCE", bash_source_v, bash_source_a);
+ GET_ARRAY_FROM_VAR ("BASH_LINENO", bash_lineno_v, bash_lineno_a);
+
+ array_push (bash_source_a, filename);
+ if (bash_lineno_a)
+ {
+ t = itos (executing_line_number ());
+ array_push (bash_lineno_a, t);
+ free (t);
+ }
+ array_push (funcname_a, "main");
+#endif
+
+#ifdef HAVE_DEV_FD
+ fd_is_tty = isatty (fd);
+#else
+ fd_is_tty = 0;
+#endif
+
+ /* Only do this with non-tty file descriptors we can seek on. */
+ if (fd_is_tty == 0 && (lseek (fd, 0L, 1) != -1))
+ {
+ /* Check to see if the `file' in `bash file' is a binary file
+ according to the same tests done by execute_simple_command (),
+ and report an error and exit if it is. */
+ sample_len = read (fd, sample, sizeof (sample));
+ if (sample_len < 0)
+ {
+ e = errno;
+ if ((fstat (fd, &sb) == 0) && S_ISDIR (sb.st_mode))
+ internal_error (_("%s: is a directory"), filename);
+ else
+ {
+ errno = e;
+ file_error (filename);
+ }
+ exit (EX_NOEXEC);
+ }
+ else if (sample_len > 0 && (check_binary_file (sample, sample_len)))
+ {
+ internal_error (_("%s: cannot execute binary file"), filename);
+ exit (EX_BINARY_FILE);
+ }
+ /* Now rewind the file back to the beginning. */
+ 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, 1, -1);
+
+#if defined (BUFFERED_INPUT)
+ default_buffered_input = fd;
+ SET_CLOSE_ON_EXEC (default_buffered_input);
+#else /* !BUFFERED_INPUT */
+ default_input = fdopen (fd, "r");
+
+ if (default_input == 0)
+ {
+ file_error (filename);
+ exit (EX_NOTFOUND);
+ }
+
+ SET_CLOSE_ON_EXEC (fd);
+ if (fileno (default_input) != fd)
+ SET_CLOSE_ON_EXEC (fileno (default_input));
+#endif /* !BUFFERED_INPUT */
+
+ /* Just about the only way for this code to be executed is if something
+ like `bash -i /dev/stdin' is executed. */
+ if (interactive_shell && fd_is_tty)
+ {
+ dup2 (fd, 0);
+ close (fd);
+ fd = 0;
+#if defined (BUFFERED_INPUT)
+ default_buffered_input = 0;
+#else
+ fclose (default_input);
+ default_input = stdin;
+#endif
+ }
+ else if (forced_interactive && fd_is_tty == 0)
+ /* But if a script is called with something like `bash -i scriptname',
+ we need to do a non-interactive setup here, since we didn't do it
+ before. */
+ init_interactive_script ();
+
+ free (filename);
+ return (fd);
+}
+
+/* Initialize the input routines for the parser. */
+static void
+set_bash_input ()
+{
+ /* Make sure the fd from which we are reading input is not in
+ no-delay mode. */
+#if defined (BUFFERED_INPUT)
+ if (interactive == 0)
+ sh_unset_nodelay_mode (default_buffered_input);
+ else
+#endif /* !BUFFERED_INPUT */
+ sh_unset_nodelay_mode (fileno (stdin));
+
+ /* with_input_from_stdin really means `with_input_from_readline' */
+ if (interactive && no_line_editing == 0)
+ with_input_from_stdin ();
+#if defined (BUFFERED_INPUT)
+ else if (interactive == 0)
+ with_input_from_buffered_stream (default_buffered_input, dollar_vars[0]);
+#endif /* BUFFERED_INPUT */
+ else
+ with_input_from_stream (default_input, dollar_vars[0]);
+}
+
+/* Close the current shell script input source and forget about it. This is
+ extern so execute_cmd.c:initialize_subshell() can call it. If CHECK_ZERO
+ is non-zero, we close default_buffered_input even if it's the standard
+ input (fd 0). */
+void
+unset_bash_input (check_zero)
+ int check_zero;
+{
+#if defined (BUFFERED_INPUT)
+ if ((check_zero && default_buffered_input >= 0) ||
+ (check_zero == 0 && default_buffered_input > 0))
+ {
+ close_buffered_fd (default_buffered_input);
+ default_buffered_input = bash_input.location.buffered_fd = -1;
+ bash_input.type = st_none; /* XXX */
+ }
+#else /* !BUFFERED_INPUT */
+ if (default_input)
+ {
+ fclose (default_input);
+ default_input = (FILE *)NULL;
+ }
+#endif /* !BUFFERED_INPUT */
+}
+
+
+#if !defined (PROGRAM)
+# define PROGRAM "bash"
+#endif
+
+static void
+set_shell_name (argv0)
+ char *argv0;
+{
+ /* Here's a hack. If the name of this shell is "sh", then don't do
+ any startup files; just try to be more like /bin/sh. */
+ shell_name = argv0 ? base_pathname (argv0) : PROGRAM;
+
+ if (argv0 && *argv0 == '-')
+ {
+ if (*shell_name == '-')
+ shell_name++;
+ login_shell = 1;
+ }
+
+ if (shell_name[0] == 's' && shell_name[1] == 'h' && shell_name[2] == '\0')
+ act_like_sh++;
+ if (shell_name[0] == 's' && shell_name[1] == 'u' && shell_name[2] == '\0')
+ su_shell++;
+
+ shell_name = argv0 ? argv0 : PROGRAM;
+ FREE (dollar_vars[0]);
+ dollar_vars[0] = savestring (shell_name);
+
+ /* A program may start an interactive shell with
+ "execl ("/bin/bash", "-", NULL)".
+ If so, default the name of this shell to our name. */
+ if (!shell_name || !*shell_name || (shell_name[0] == '-' && !shell_name[1]))
+ shell_name = PROGRAM;
+}
+
+static void
+init_interactive ()
+{
+ expand_aliases = interactive_shell = startup_state = 1;
+ interactive = 1;
+}
+
+static void
+init_noninteractive ()
+{
+#if defined (HISTORY)
+ bash_history_reinit (0);
+#endif /* HISTORY */
+ interactive_shell = startup_state = interactive = 0;
+ expand_aliases = posixly_correct; /* XXX - was 0 not posixly_correct */
+ no_line_editing = 1;
+#if defined (JOB_CONTROL)
+ /* Even if the shell is not interactive, enable job control if the -i or
+ -m option is supplied at startup. */
+ set_job_control (forced_interactive||jobs_m_flag);
+#endif /* JOB_CONTROL */
+}
+
+static void
+init_interactive_script ()
+{
+ init_noninteractive ();
+ expand_aliases = interactive_shell = startup_state = 1;
+}
+
+void
+get_current_user_info ()
+{
+ struct passwd *entry;
+
+ /* Don't fetch this more than once. */
+ if (current_user.user_name == 0)
+ {
+#if defined (__TANDEM)
+ entry = getpwnam (getlogin ());
+#else
+ entry = getpwuid (current_user.uid);
+#endif
+ if (entry)
+ {
+ current_user.user_name = savestring (entry->pw_name);
+ current_user.shell = (entry->pw_shell && entry->pw_shell[0])
+ ? savestring (entry->pw_shell)
+ : savestring ("/bin/sh");
+ current_user.home_dir = savestring (entry->pw_dir);
+ }
+ else
+ {
+ current_user.user_name = _("I have no name!");
+ current_user.user_name = savestring (current_user.user_name);
+ current_user.shell = savestring ("/bin/sh");
+ current_user.home_dir = savestring ("/");
+ }
+ endpwent ();
+ }
+}
+
+/* Do whatever is necessary to initialize the shell.
+ Put new initializations in here. */
+static void
+shell_initialize ()
+{
+ char hostname[256];
+
+ /* Line buffer output for stderr and stdout. */
+ if (shell_initialized == 0)
+ {
+ sh_setlinebuf (stderr);
+ sh_setlinebuf (stdout);
+ }
+
+ /* Sort the array of shell builtins so that the binary search in
+ find_shell_builtin () works correctly. */
+ initialize_shell_builtins ();
+
+ /* Initialize the trap signal handlers before installing our own
+ signal handlers. traps.c:restore_original_signals () is responsible
+ for restoring the original default signal handlers. That function
+ is called when we make a new child. */
+ initialize_traps ();
+ initialize_signals (0);
+
+ /* It's highly unlikely that this will change. */
+ if (current_host_name == 0)
+ {
+ /* Initialize current_host_name. */
+ if (gethostname (hostname, 255) < 0)
+ current_host_name = "??host??";
+ else
+ current_host_name = savestring (hostname);
+ }
+
+ /* Initialize the stuff in current_user that comes from the password
+ file. We don't need to do this right away if the shell is not
+ interactive. */
+ if (interactive_shell)
+ get_current_user_info ();
+
+ /* Initialize our interface to the tilde expander. */
+ tilde_initialize ();
+
+ /* Initialize internal and environment variables. Don't import shell
+ functions from the environment if we are running in privileged or
+ restricted mode or if the shell is running setuid. */
+#if defined (RESTRICTED_SHELL)
+ initialize_shell_variables (shell_environment, privileged_mode||restricted||running_setuid);
+#else
+ initialize_shell_variables (shell_environment, privileged_mode||running_setuid);
+#endif
+
+ /* Initialize the data structures for storing and running jobs. */
+ initialize_job_control (jobs_m_flag);
+
+ /* Initialize input streams to null. */
+ initialize_bash_input ();
+
+ initialize_flags ();
+
+ /* Initialize the shell options. Don't import the shell options
+ from the environment variables $SHELLOPTS or $BASHOPTS if we are
+ running in privileged or restricted mode or if the shell is running
+ setuid. */
+#if defined (RESTRICTED_SHELL)
+ initialize_shell_options (privileged_mode||restricted||running_setuid);
+ initialize_bashopts (privileged_mode||restricted||running_setuid);
+#else
+ initialize_shell_options (privileged_mode||running_setuid);
+ initialize_bashopts (privileged_mode||running_setuid);
+#endif
+}
+
+/* Function called by main () when it appears that the shell has already
+ had some initialization performed. This is supposed to reset the world
+ back to a pristine state, as if we had been exec'ed. */
+static void
+shell_reinitialize ()
+{
+ /* The default shell prompts. */
+ primary_prompt = PPROMPT;
+ secondary_prompt = SPROMPT;
+
+ /* Things that get 1. */
+ current_command_number = 1;
+
+ /* We have decided that the ~/.bashrc file should not be executed
+ for the invocation of each shell script. If the variable $ENV
+ (or $BASH_ENV) is set, its value is used as the name of a file
+ to source. */
+ no_rc = no_profile = 1;
+
+ /* Things that get 0. */
+ login_shell = make_login_shell = interactive = executing = 0;
+ debugging = do_version = line_number = last_command_exit_value = 0;
+ forced_interactive = interactive_shell = subshell_environment = 0;
+ expand_aliases = 0;
+
+ /* XXX - should we set jobs_m_flag to 0 here? */
+
+#if defined (HISTORY)
+ bash_history_reinit (0);
+#endif /* HISTORY */
+
+#if defined (RESTRICTED_SHELL)
+ restricted = 0;
+#endif /* RESTRICTED_SHELL */
+
+ /* Ensure that the default startup file is used. (Except that we don't
+ execute this file for reinitialized shells). */
+ bashrc_file = DEFAULT_BASHRC;
+
+ /* Delete all variables and functions. They will be reinitialized when
+ the environment is parsed. */
+ delete_all_contexts (shell_variables);
+ delete_all_variables (shell_functions);
+
+ reinit_special_variables ();
+
+#if defined (READLINE)
+ bashline_reinitialize ();
+#endif
+
+ shell_reinitialized = 1;
+}
+
+static void
+show_shell_usage (fp, extra)
+ FILE *fp;
+ int extra;
+{
+ int i;
+ char *set_opts, *s, *t;
+
+ if (extra)
+ fprintf (fp, _("GNU bash, version %s-(%s)\n"), shell_version_string (), MACHTYPE);
+ fprintf (fp, _("Usage:\t%s [GNU long option] [option] ...\n\t%s [GNU long option] [option] script-file ...\n"),
+ shell_name, shell_name);
+ fputs (_("GNU long options:\n"), fp);
+ for (i = 0; long_args[i].name; i++)
+ fprintf (fp, "\t--%s\n", long_args[i].name);
+
+ fputs (_("Shell options:\n"), fp);
+ fputs (_("\t-ilrsD or -c command or -O shopt_option\t\t(invocation only)\n"), fp);
+
+ for (i = 0, set_opts = 0; shell_builtins[i].name; i++)
+ if (STREQ (shell_builtins[i].name, "set"))
+ set_opts = savestring (shell_builtins[i].short_doc);
+ if (set_opts)
+ {
+ s = strchr (set_opts, '[');
+ if (s == 0)
+ s = set_opts;
+ while (*++s == '-')
+ ;
+ t = strchr (s, ']');
+ if (t)
+ *t = '\0';
+ fprintf (fp, _("\t-%s or -o option\n"), s);
+ free (set_opts);
+ }
+
+ if (extra)
+ {
+ fprintf (fp, _("Type `%s -c \"help set\"' for more information about shell options.\n"), shell_name);
+ fprintf (fp, _("Type `%s -c help' for more information about shell builtin commands.\n"), shell_name);
+ fprintf (fp, _("Use the `bashbug' command to report bugs.\n"));
+ }
+}
+
+static void
+add_shopt_to_alist (opt, on_or_off)
+ char *opt;
+ int on_or_off;
+{
+ if (shopt_ind >= shopt_len)
+ {
+ shopt_len += 8;
+ shopt_alist = (STRING_INT_ALIST *)xrealloc (shopt_alist, shopt_len * sizeof (shopt_alist[0]));
+ }
+ shopt_alist[shopt_ind].word = opt;
+ shopt_alist[shopt_ind].token = on_or_off;
+ shopt_ind++;
+}
+
+static void
+run_shopt_alist ()
+{
+ register int i;
+
+ for (i = 0; i < shopt_ind; i++)
+ if (shopt_setopt (shopt_alist[i].word, (shopt_alist[i].token == '-')) != EXECUTION_SUCCESS)
+ exit (EX_BADUSAGE);
+ free (shopt_alist);
+ shopt_alist = 0;
+ shopt_ind = shopt_len = 0;
+}
static int nfifo;
static int fifo_list_size;
+void
+clear_fifo_list ()
+{
+}
+
char *
copy_fifo_list (sizep)
int *sizep;
static int nfds;
static int totfds; /* The highest possible number of open files. */
+void
+clear_fifo (i)
+ int i;
+{
+ if (dev_fd_list[i])
+ {
+ dev_fd_list[i] = 0;
+ nfds--;
+ }
+}
+
+void
+clear_fifo_list ()
+{
+ register int i;
+
+ if (nfds == 0)
+ return;
+
+ for (i = 0; nfds && i < totfds; i++)
+ clear_fifo (i);
+
+ nfds = 0;
+}
+
char *
copy_fifo_list (sizep)
int *sizep;
extern void unlink_new_fifos __P((char *, int));
extern void close_new_fifos __P((char *, int));
+extern void clear_fifo_list __P((void));
+
extern WORD_LIST *list_string_with_quotes __P((char *));
#if defined (ARRAY_VARS)
--version) shift ; do_version=y ;;
--) shift ; break ;;
-*) echo "bashbug: ${1}: invalid option" >&2
- echo "$USAGE" >& 2
+ echo "$USAGE" >&2
exit 2 ;;
*) break ;;
esac
--- /dev/null
+#!/bin/sh -
+#
+# bashbug - create a bug report and mail it to the bug address
+#
+# The bug address depends on the release status of the shell. Versions
+# with status `devel', `alpha', `beta', or `rc' mail bug reports to
+# chet@cwru.edu and, optionally, to bash-testers@cwru.edu.
+# Other versions send mail to bug-bash@gnu.org.
+#
+# Copyright (C) 1996-2004 Free Software Foundation, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#
+# configuration section:
+# these variables are filled in by the make target in Makefile
+#
+MACHINE="!MACHINE!"
+OS="!OS!"
+CC="!CC!"
+CFLAGS="!CFLAGS!"
+RELEASE="!RELEASE!"
+PATCHLEVEL="!PATCHLEVEL!"
+RELSTATUS="!RELSTATUS!"
+MACHTYPE="!MACHTYPE!"
+
+PATH=/bin:/usr/bin:/usr/local/bin:$PATH
+export PATH
+
+# Check if TMPDIR is set, default to /tmp
+: ${TMPDIR:=/tmp}
+
+#Securely create a temporary directory for the temporary files
+TEMPDIR=$TMPDIR/bbug.$$
+(umask 077 && mkdir $TEMPDIR) || {
+ echo "$0: could not create temporary directory" >&2
+ exit 1
+}
+
+TEMPFILE1=$TEMPDIR/bbug1
+TEMPFILE2=$TEMPDIR/bbug2
+
+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
+bug-bash mailing list 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'`
+case "$N" in
+*c) n=-n c= ;;
+*) n= c='\c' ;;
+esac
+
+BASHTESTERS="bash-testers@cwru.edu"
+
+case "$RELSTATUS" in
+alpha*|beta*|devel*|rc*) BUGBASH=chet@cwru.edu ;;
+*) BUGBASH=bug-bash@gnu.org ;;
+esac
+
+case "$RELSTATUS" in
+alpha*|beta*|devel*|rc*)
+ 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
+ case "$ans" in
+ y*|Y*) BUGBASH="${BUGBASH},${BASHTESTERS}" ;;
+ esac ;;
+esac
+
+BUGADDR="${1-$BUGBASH}"
+
+if [ -z "$DEFEDITOR" ] && [ -z "$EDITOR" ]; then
+ if [ -x /usr/bin/editor ]; then
+ DEFEDITOR=editor
+ elif [ -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`}}
+
+trap 'rm -rf "$TEMPDIR"; exit 1' 1 2 3 13 15
+trap 'rm -rf "$TEMPDIR"' 0
+
+UN=
+if (uname) >/dev/null 2>&1; then
+ UN=`uname -a`
+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
+
+INITIAL_SUBJECT='[50 character or so descriptive subject here (for reference)]'
+
+cat > "$TEMPFILE1" <<EOF
+From: ${USER}
+To: ${BUGADDR}
+Subject: ${INITIAL_SUBJECT}
+
+Configuration Information [Automatically generated, do not change]:
+Machine: $MACHINE
+OS: $OS
+Compiler: $CC
+Compilation CFLAGS: $CFLAGS
+uname output: $UN
+Machine Type: $MACHTYPE
+
+Bash Version: $RELEASE
+Patch Level: $PATCHLEVEL
+Release Status: $RELSTATUS
+
+Description:
+ [Detailed description of the problem, suggestion, or complaint.]
+
+Repeat-By:
+ [Describe the sequence of events that causes the problem
+ to occur.]
+
+Fix:
+ [Description of how to fix the problem. If you don't know a
+ fix for the problem, don't include this section.]
+EOF
+
+cp "$TEMPFILE1" "$TEMPFILE2"
+chmod u+w "$TEMPFILE1"
+
+trap '' 2 # ignore interrupts while in editor
+
+edstat=1
+while [ $edstat -ne 0 ]; do
+ $EDITOR "$TEMPFILE1"
+ edstat=$?
+
+ if [ $edstat -ne 0 ]; then
+ echo "$0: editor \`$EDITOR' exited with nonzero status."
+ echo "$0: Perhaps it was interrupted."
+ echo "$0: Type \`y' to give up, and lose your bug report;"
+ echo "$0: type \`n' to re-enter the editor."
+ echo $n "$0: Do you want to give up? $c"
+
+ read ans
+ case "$ans" in
+ [Yy]*) exit 1 ;;
+ esac
+
+ continue
+ fi
+
+ # find the subject from the temp file and see if it's been changed
+ CURR_SUB=`grep '^Subject: ' "$TEMPFILE1" | sed 's|^Subject:[ ]*||' | sed 1q`
+
+ case "$CURR_SUB" in
+ "${INITIAL_SUBJECT}")
+ echo
+ echo "$0: You have not changed the subject from the default."
+ echo "$0: Please use a more descriptive subject header."
+ echo "$0: Type \`y' to give up, and lose your bug report;"
+ echo "$0: type \`n' to re-enter the editor."
+ echo $n "$0: Do you want to give up? $c"
+
+ read ans
+ case "$ans" in
+ [Yy]*) exit 1 ;;
+ esac
+
+ echo "$0: The editor will be restarted in five seconds."
+ sleep 5
+ edstat=1
+ ;;
+ esac
+
+done
+
+trap 'rm -rf "$TEMPDIR"; exit 1' 2 # restore trap on SIGINT
+
+if cmp -s "$TEMPFILE1" "$TEMPFILE2"
+then
+ echo "File not changed, no bug report submitted."
+ exit
+fi
+
+echo $n "Send bug report to ${BUGADDR}? [y/n] $c"
+read ans
+case "$ans" in
+[Nn]*) exit 0 ;;
+esac
+
+${RMAIL} $SMARGS < "$TEMPFILE1" || {
+ cat "$TEMPFILE1" >> $HOME/dead.bashbug
+ echo "$0: mail to ${BUGADDR} failed: report saved in $HOME/dead.bashbug" >&2
+}
+
+exit 0