Commit d600ac11 authored by Daniel Kahn Gillmor's avatar Daniel Kahn Gillmor

Import Upstream version 4.4~rc1+b2

parent c19e47e8
This document details the changes between this version, bash-4.4-beta2, and
the previous version, bash-4.4-rc1.
1. Changes to Bash
a. Fixed a memory leak when processing ${!var[@]}.
b. Fixed a bug that caused subshells to free trap strings associated with
inherited signals.
c. Inheriting BASHOPTS from the environment now works to force actions
associated with enabling an option, instead of just marking the option
as enabled.
d. Fixed a bug that allowed assignments to BASH_CMDS when the shell was in
restricted mode.
e. Fixed a bug caused by an accidental omission of part of the original patch
for EXECIGNORE.
e. Prompt expansion now quotes the results of the \s, \h, and \H expansions.
f. Fixed a bug that caused parsing errors in command substitutions with
consecutive case statements separated by newlines.
g. Updated logic used to decide whether bash is running inside an emacs
terminal emulator to work with future emacs versions.
h. Fixed two extended pattern matching bugs caused by premature short-
circuiting.
i. Fixed a memory leak in the code that removes duplicate history entries.
j. There are a number of bug fixes to coproc, mapfile, declare, unset,
and assignment statements that prevent nameref variables from creating
and unsetting variables with invalid names.
k. Fixed a bug that caused variables to be inadvertently marked as both an
associative and an indexed array.
l. Fixed a bug that caused `bash -c' to not run a trap specified in the
command string.
j. There are a number of bug fixes to coproc, mapfile, declare, and assignment
statements that prevent nameref variables from overwriting or modifying
attributes of readonly variables.
k. Fixed a bug that caused command substitution to attempt to set the
terminal's process group incorrectly.
l. Fixed a bug that could cause prompt string expansion to display error
messages when the `nounset' shell option is set.
m. Fixed a bug that caused "$@" to not expand to an empty string under the
circumstances when Posix says it should ("${@-${@-$@}}").
n. Fixed several bugs caused by referencing nameref variables whose values
are names of unset variables (or names that are valid for referencing
but not assignment), including creating variables in the temporary
environment.
o. Function tracing and error tracing are disabled if --debugger is supplied
at startup but the shell can't find the debugger start file.
p. Fixed a bug when IFS is used as the control variable in a for statement.
q. Fixed a bug with SIGINT received by a command substitution in an interactive
shell.
r. The checks for nameref variable self-references are more thorough.
s. Fixed several bugs with multi-line aliases.
t. Fixed `test' to handle the four-argument case where $1 == '(' and
$4 == ')'.
u. Fixed a bug in the expansion of $* in the cases where word splitting is
not performed.
v. Fixed a bug in execution of case statements where IFS includes the
pattern matching characters.
2. Changes to Readline
a. When refreshing the line as the result of a key sequence, Readline attempts
to redraw only the last line of a multiline prompt.
b. Fixed an issue that caused completion of git commands to display
incorrectly when using colored-completion-prefix.
c. Fixed several redisplay bugs having to do with multibyte characters and
invisible characters in prompt strings.
3. New Features in Bash
a. Value conversions (arithmetic expansions, case modification, etc.) now
happen when assigning elements of an array using compound assignment.
b. There is a new option settable in config-top.h that makes multiple
directory arguments to `cd' a fatal error.
c. Bash now uses mktemp() when creating internal temporary files; it produces
a warning at build time on many Linux systems.
4. New Features in Readline
a. The default binding for ^W in vi mode now uses word boundaries specified
by Posix (vi-unix-word-rubout is bindable command name).
b. rl_clear_visible_line: new application-callable function; clears all
screen lines occupied by the current visible readline line.
c. rl_tty_set_echoing: application-callable function that controls whether
or not readline thinks it is echoing terminal output.
d. Handle >| and strings of digits preceding and following redirection
specifications as single tokens when tokenizing the line for history
expansion.
e. Fixed a bug with displaying completions when the prefix display length
is greater than the length of the completions to be displayed.
f. The :p history modifier now applies to the entire line, so any expansion
specifying :p causes the line to be printed instead of expanded.
------------------------------------------------------------------------------
This document details the changes between this version, bash-4.4-rc1, and
the previous version, bash-4.4-beta.
......
This diff is collapsed.
......@@ -57,6 +57,8 @@ code directory by typing 'make clean'. To also remove the files that
'configure' created (so you can compile Bash for a different kind of
computer), type 'make distclean'.
Next: Compiling For Multiple Architectures, Prev: Basic Installation, Up: Installing Bash
Compilers and Options
=====================
......@@ -74,6 +76,8 @@ On systems that have the 'env' program, you can do it like this:
The configuration process uses GCC to build Bash if it is available.
Next: Installation Names, Prev: Compilers and Options, Up: Installing Bash
Compiling For Multiple Architectures
====================================
......@@ -104,6 +108,8 @@ The 'mkclone' script requires Bash, so you must have already built Bash
for at least one architecture before you can create build directories
for other architectures.
Next: Specifying the System Type, Prev: Compiling For Multiple Architectures, Up: Installing Bash
Installation Names
==================
......@@ -119,6 +125,8 @@ option '--exec-prefix=PATH', 'make install' will use PATH as the prefix
for installing programs and libraries. Documentation and other data
files will still use the regular prefix.
Next: Sharing Defaults, Prev: Installation Names, Up: Installing Bash
Specifying the System Type
==========================
......@@ -132,6 +140,8 @@ canonical name with three fields: 'CPU-COMPANY-SYSTEM' (e.g.,
See the file 'support/config.sub' for the possible values of each field.
Next: Operation Controls, Prev: Specifying the System Type, Up: Installing Bash
Sharing Defaults
================
......@@ -144,6 +154,8 @@ looks for 'PREFIX/share/config.site' if it exists, then
A warning: the Bash 'configure' looks for a site script, but not all
'configure' scripts do.
Next: Optional Features, Prev: Sharing Defaults, Up: Installing Bash
Operation Controls
==================
......@@ -173,6 +185,8 @@ Operation Controls
'configure' also accepts some other, not widely used, boilerplate
options. 'configure --help' prints the complete list.
Prev: Operation Controls, Up: Installing Bash
Optional Features
=================
......
......@@ -887,6 +887,7 @@ tests/comsub.tests f
tests/comsub.right f
tests/comsub1.sub f
tests/comsub2.sub f
tests/comsub3.sub f
tests/comsub-eof.tests f
tests/comsub-eof0.sub f
tests/comsub-eof1.sub f
......@@ -983,11 +984,13 @@ tests/extglob.tests f
tests/extglob.right f
tests/extglob1.sub f
tests/extglob1a.sub f
tests/extglob3.sub f
tests/extglob2.sub f
tests/extglob2.tests f
tests/extglob2.right f
tests/extglob3.sub f
tests/extglob3.tests f
tests/extglob3.right f
tests/extglob4.sub f
tests/func.tests f
tests/func.right f
tests/func1.sub f
......@@ -1005,6 +1008,7 @@ tests/getopts6.sub f
tests/getopts7.sub f
tests/getopts8.sub f
tests/getopts9.sub f
tests/getopts10.sub f
tests/glob.tests f
tests/glob1.sub f
tests/glob.right f
......@@ -1058,6 +1062,7 @@ tests/jobs.right f
tests/lastpipe.right f
tests/lastpipe.tests f
tests/lastpipe1.sub f
tests/lastpipe2.sub f
tests/mapfile.data f
tests/mapfile.right f
tests/mapfile.tests f
......@@ -1076,6 +1081,14 @@ tests/nameref7.sub f
tests/nameref8.sub f
tests/nameref9.sub f
tests/nameref10.sub f
tests/nameref11.sub f
tests/nameref12.sub f
tests/nameref13.sub f
tests/nameref14.sub f
tests/nameref15.sub f
tests/nameref16.sub f
tests/nameref17.sub f
tests/nameref18.sub f
tests/nameref.right f
tests/new-exp.tests f
tests/new-exp1.sub f
......
......@@ -120,22 +120,33 @@ ii. inherit_errexit: a new `shopt' option that, when set, causes command
substitutions to inherit the -e option. By default, those subshells disable
-e. It's enabled as part of turning on posix mode.
jj. New prompt string: PS0. Expanded and displayed by interactive shells after
jj. New prompt string: PS0. Expanded and displayed by interactive shells after
reading a complete command but before executing it.
kk. Interactive shells now behave as if SIGTSTP/SIGTTIN/SIGTTOU are set to SIG_DFL
when the shell is started, so they are set to SIG_DFL in child processes.
kk. Interactive shells now behave as if SIGTSTP/SIGTTIN/SIGTTOU are set to
SIG_DFL when the shell is started, so they are set to SIG_DFL in child
processes.
ll. Posix-mode shells now allow double quotes to quote the history expansion
character.
mm. OLDPWD can be inherited from the environment if it names a directory.
nn. Shells running as root no longer inherit PS4 from the environment, closing a
security hole involving PS4 expansion performing command substitution.
nn. Shells running as root no longer inherit PS4 from the environment, closing
a security hole involving PS4 expansion performing command substitution.
oo. If executing an implicit `cd' when the `autocd' option is set, bash will
now invoke a function named `cd' if one exists before executing the `cd'
builtin.
pp. Value conversions (arithmetic expansions, case modification, etc.) now
happen when assigning elements of an array using compound assignment.
oo. If executing an implicit `cd' when the `autocd' option is set, bash will now
invoke a function named `cd' if one exists before executing the `cd' builtin.
qq. There is a new option settable in config-top.h that makes multiple
directory arguments to `cd' a fatal error.
rr. Bash now uses mktemp() when creating internal temporary files; it produces
a warning at build time on many Linux systems.
2. New Features in Readline
......@@ -182,6 +193,25 @@ k. If readline reads a history file that begins with `#' (or the value of
l. Readline now throws an error if it parses a key binding without a terminating
`:' or whitespace.
m. The default binding for ^W in vi mode now uses word boundaries specified
by Posix (vi-unix-word-rubout is bindable command name).
n. rl_clear_visible_line: new application-callable function; clears all
screen lines occupied by the current visible readline line.
o. rl_tty_set_echoing: application-callable function that controls whether
or not readline thinks it is echoing terminal output.
p. Handle >| and strings of digits preceding and following redirection
specifications as single tokens when tokenizing the line for history
expansion.
q. Fixed a bug with displaying completions when the prefix display length
is greater than the length of the completions to be displayed.
r. The :p history modifier now applies to the entire line, so any expansion
specifying :p causes the line to be printed instead of expanded.
-------------------------------------------------------------------------------
This is a terse description of the new features added to bash-4.3 since
the release of bash-4.2. As always, the manual page (doc/bash.1) is
......
......@@ -209,6 +209,9 @@ The following list is what's changed when 'POSIX mode' is in effect:
'read', the trap handler executes and 'read' returns an exit status
greater than 128.
54. Bash removes an exited background process's status from the list
of such statuses after the 'wait' builtin is used to obtain it.
There is other POSIX behavior that Bash does not implement by default
even when in POSIX mode. Specifically:
......
......@@ -87,6 +87,12 @@ convert_var_to_array (var)
VSETATTR (var, att_array);
VUNSETATTR (var, att_invisible);
/* Make sure it's not marked as an associative array any more */
VUNSETATTR (var, att_assoc);
/* Since namerefs can't be array variables, turn off nameref attribute */
VUNSETATTR (var, att_nameref);
return var;
}
......@@ -118,6 +124,12 @@ convert_var_to_assoc (var)
VSETATTR (var, att_assoc);
VUNSETATTR (var, att_invisible);
/* Make sure it's not marked as an indexed array any more */
VUNSETATTR (var, att_array);
/* Since namerefs can't be array variables, turn off nameref attribute */
VUNSETATTR (var, att_nameref);
return var;
}
......@@ -204,6 +216,15 @@ bind_array_variable (name, ind, value, flags)
entry = find_shell_variable (name);
if (entry == (SHELL_VAR *) 0)
{
/* Is NAME a nameref variable that points to an unset variable? */
entry = find_variable_nameref_for_create (name, 0);
if (entry == INVALID_NAMEREF_VALUE)
return ((SHELL_VAR *)0);
if (entry && nameref_p (entry))
entry = make_new_array_variable (nameref_cell (entry));
}
if (entry == (SHELL_VAR *) 0)
entry = make_new_array_variable (name);
else if ((readonly_p (entry) && (flags&ASS_FORCE) == 0) || noassign_p (entry))
......@@ -259,7 +280,7 @@ assign_array_element (name, value, flags)
{
char *sub, *vname;
int sublen;
SHELL_VAR *entry;
SHELL_VAR *entry, *nv;
vname = array_variable_name (name, &sub, &sublen);
......@@ -341,9 +362,21 @@ find_or_make_array_variable (name, flags)
{
/* See if we have a nameref pointing to a variable that hasn't been
created yet. */
var = find_variable_last_nameref (name);
var = find_variable_last_nameref (name, 1);
if (var && nameref_p (var) && invisible_p (var))
{
internal_warning (_("%s: removing nameref attribute"), name);
VUNSETATTR (var, att_nameref);
}
if (var && nameref_p (var))
var = (flags & 2) ? make_new_assoc_variable (nameref_cell (var)) : make_new_array_variable (nameref_cell (var));
{
if (valid_nameref_value (nameref_cell (var), 2) == 0)
{
sh_invalidid (nameref_cell (var));
return ((SHELL_VAR *)NULL);
}
var = (flags & 2) ? make_new_assoc_variable (nameref_cell (var)) : make_new_array_variable (nameref_cell (var));
}
}
if (var == 0)
......@@ -403,10 +436,7 @@ assign_array_var_from_word_list (var, list, flags)
i = (flags & ASS_APPEND) ? array_max_index (a) + 1 : 0;
for (l = list; l; l = l->next, i++)
if (var->assign_func)
(*var->assign_func) (var, l->word->word, i, 0);
else
array_insert (a, i, l->word->word);
bind_array_var_internal (var, i, 0, l->word->word, flags & ~ASS_APPEND);
VUNSETATTR (var, att_invisible); /* no longer invisible */
......@@ -869,6 +899,8 @@ valid_array_reference (name, flags)
len = skipsubscript (t, 0, 0);
if (t[len] != ']' || len == 1)
return 0;
if (t[len+1] != '\0')
return 0;
for (r = 1; r < len; r++)
if (whitespace (t[r]) == 0)
return 1;
......@@ -969,7 +1001,7 @@ array_variable_part (s, subp, lenp)
t = array_variable_name (s, subp, lenp);
if (t == 0)
return ((SHELL_VAR *)NULL);
var = find_variable (t);
var = find_variable (t); /* XXX - handle namerefs here? */
free (t);
return var; /* now return invisible variables; caller must handle */
......@@ -1055,7 +1087,7 @@ array_value_internal (s, quoted, flags, rtype, indp)
free (temp);
}
else /* ${name[@]} or unquoted ${name[*]} */
retval = string_list_dollar_at (l, quoted); /* XXX - leak here */
retval = string_list_dollar_at (l, quoted, 0); /* XXX - leak here */
dispose_words (l);
}
......@@ -1172,7 +1204,7 @@ array_keys (s, quoted)
free (temp);
}
else /* ${!name[@]} or unquoted ${!name[*]} */
retval = string_list_dollar_at (l, quoted);
retval = string_list_dollar_at (l, quoted, 0);
dispose_words (l);
return retval;
......
......@@ -188,7 +188,9 @@ extern int current_command_line_count;
extern struct dstack dstack;
extern int parser_state;
#if defined (BANG_HISTORY)
static int bash_history_inhibit_expansion __P((char *, int));
#endif
#if defined (READLINE)
static void re_edit __P((char *));
#endif
......@@ -199,6 +201,7 @@ static HIST_ENTRY *last_history_entry __P((void));
static char *expand_histignore_pattern __P((char *));
static int history_should_ignore __P((char *));
#if defined (BANG_HISTORY)
/* Is the history expansion starting at string[i] one that should not
be expanded? */
static int
......@@ -246,14 +249,15 @@ bash_history_inhibit_expansion (string, i)
else
return (0);
}
#endif
void
bash_initialize_history ()
{
history_quotes_inhibit_expansion = 1;
history_search_delimiter_chars = ";&()|<>";
history_inhibit_expansion_function = bash_history_inhibit_expansion;
#if defined (BANG_HISTORY)
history_inhibit_expansion_function = bash_history_inhibit_expansion;
sv_histchars ("histchars");
#endif
}
......@@ -265,9 +269,9 @@ bash_history_reinit (interact)
#if defined (BANG_HISTORY)
history_expansion = interact != 0;
history_expansion_inhibited = 1; /* XXX */
history_inhibit_expansion_function = bash_history_inhibit_expansion;
#endif
remember_on_history = enable_history_list;
history_inhibit_expansion_function = bash_history_inhibit_expansion;
}
void
......@@ -285,8 +289,8 @@ bash_history_enable ()
remember_on_history = enable_history_list = 1;
#if defined (BANG_HISTORY)
history_expansion_inhibited = 0;
#endif
history_inhibit_expansion_function = bash_history_inhibit_expansion;
#endif
sv_history_control ("HISTCONTROL");
sv_histignore ("HISTIGNORE");
}
......@@ -670,7 +674,9 @@ hc_erasedups (line)
if (STREQ (temp->line, line))
{
r = where_history ();
remove_history (r);
temp = remove_history (r);
if (temp)
free_history_entry (temp);
}
}
using_history ();
......
/* bashline.c -- Bash's interface to the readline library. */
/* Copyright (C) 1987-2013 Free Software Foundation, Inc.
/* Copyright (C) 1987-2016 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
......@@ -54,6 +54,7 @@
#include "pathexp.h"
#include "shmbutil.h"
#include "trap.h"
#include "flags.h"
#if defined (HAVE_MBSTR_H) && defined (HAVE_MBSCHR)
# include <mbstr.h> /* mbschr */
......@@ -980,9 +981,6 @@ edit_and_execute_command (count, c, editing_mode, 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);
......@@ -1648,6 +1646,11 @@ bash_default_completion (text, start, end, qc, compflags)
else
{
matches = rl_completion_matches (text, variable_completion_function);
/* If a single match, see if it expands to a directory name and append
a slash if it does. This requires us to expand the variable name,
so we don't want to display errors if the variable is unset. This
can happen with dynamic variables whose value has never been
requested. */
if (matches && matches[0] && matches[1] == 0)
{
t = savestring (matches[0]);
......@@ -3124,6 +3127,7 @@ bash_filename_stat_hook (dirname)
{
char *local_dirname, *new_dirname, *t;
int should_expand_dirname, return_value;
int global_nounset;
WORD_LIST *wl;
struct stat sb;
......@@ -3140,7 +3144,12 @@ bash_filename_stat_hook (dirname)
if (should_expand_dirname)
{
new_dirname = savestring (local_dirname);
/* no error messages, and expand_prompt_string doesn't longjmp so we don't
have to worry about restoring this setting. */
global_nounset = unbound_vars_is_error;
unbound_vars_is_error = 0;
wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB); /* does the right thing */
unbound_vars_is_error = global_nounset;
if (wl)
{
free (new_dirname);
......@@ -4080,8 +4089,12 @@ bash_execute_unix_command (count, key)
ce = rl_get_termcap ("ce");
if (ce) /* clear current line */
{
#if 0
fprintf (rl_outstream, "\r");
tputs (ce, 1, putx);
#else
rl_clear_visible_line ();
#endif
fflush (rl_outstream);
}
else
......@@ -4119,8 +4132,8 @@ bash_execute_unix_command (count, key)
}
}
unbind_variable ("READLINE_LINE");
unbind_variable ("READLINE_POINT");
check_unbind_variable ("READLINE_LINE");
check_unbind_variable ("READLINE_POINT");
array_needs_making = 1;
/* and restore the readline buffer and display after command execution. */
......
......@@ -87,6 +87,7 @@ alias_builtin (list)
pflag = 1;
dflags |= AL_REUSABLE;
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
......
This file is cd.def, from which is created cd.c. It implements the
builtins "cd" and "pwd" in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2016 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
......@@ -329,6 +329,13 @@ cd_builtin (list)
builtin_error (_("too many arguments"));
return (EXECUTION_FAILURE);
}
#endif
#if 0
else if (list->word->word[0] == '\0')
{
builtin_error (_("null directory"));
return (EXECUTION_FAILURE);
}
#endif
else if (list->word->word[0] == '-' && list->word->word[1] == '\0')
{
......
......@@ -813,6 +813,7 @@ compopt_builtin (list)
case 'E':
Eflag = 1;
break;
CASE_HELPOPT;
default:
builtin_usage ();
return (EX_USAGE);
......
This diff is collapsed.
......@@ -104,7 +104,12 @@ should_suppress_fork (command)
running_trap == 0 &&
*bash_input.location.string == '\0' &&
command->type == cm_simple &&
#if 0
signal_is_trapped (EXIT_TRAP) == 0 &&
signal_is_trapped (ERROR_TRAP) == 0 &&
#else
any_signals_trapped () < 0 &&
#endif
command->redirects == 0 && command->value.Simple->redirects == 0 &&
((command->flags & CMD_TIME_PIPELINE) == 0) &&
((command->flags & CMD_INVERT_RETURN) == 0));
......@@ -262,6 +267,7 @@ parse_and_execute (string, from_file, flags)
current_token = '\n'; /* reset_parser() ? */
with_input_from_string (string, from_file);
clear_shell_input_line ();
while (*(bash_input.location.string))
{
command = (COMMAND *)NULL;
......@@ -384,7 +390,8 @@ parse_and_execute (string, from_file, flags)
* we're not going to run the exit trap AND
* we have a simple command without redirections AND
* the command is not being timed AND
* the command's return status is not being inverted
* the command's return status is not being inverted AND
* there aren't any traps in effect
* THEN
* tell the execution code that we don't need to fork
*/
......@@ -491,7 +498,7 @@ parse_string (string, from_file, flags, endp)
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &ps_sigmask);
#endif
/* itrace("parse_string: `%s'", string); */
/*itrace("parse_string: `%s'", string);*/
/* Reset the line number if the caller wants us to. If we don't reset the
line number, we have to subtract one, because we will add one just
before executing the next command (resetting the line number sets it to
......
......@@ -447,6 +447,13 @@ fc_builtin (list)
return (EXECUTION_FAILURE);
}
#if defined (READLINE)
/* If we're executing as part of a dispatched readline commnand like
{emacs,vi}_edit_and_execute_command, the readline state will indicate it.
We could remove the partial command from the history, but ksh93 doesn't
so we stay compatible. */
#endif
/* Make sure parse_and_execute doesn't turn this off, even though a
call to parse_and_execute farther up the function call stack (e.g.,
if this is called by vi_edit_and_execute_command) may have already
......
......@@ -74,6 +74,7 @@ $END
#endif
#include "../bashansi.h"
#include "../bashintl.h"
#include "../shell.h"
#include "common.h"
......@@ -86,6 +87,7 @@ $END
extern char *this_command_name;
static int getopts_unbind_variable __P((char *));
static int getopts_bind_variable __P((char *, char *));
static int dogetopts __P((int, char **));
......@@ -99,6 +101,17 @@ getopts_reset (newind)
sh_badopt = 0;
}
static int
<