Commit 2c296e46 authored by Daniel Kahn Gillmor's avatar Daniel Kahn Gillmor

Import Upstream version 5.0

parent fd562d4d
This document details the changes between this version, bash-5.0-release, and
the previous version, bash-5.0-rc1.
1. Changes to Bash
a. Tilde expansion isn't performed on indexed array subscripts, even for
backwards compatibility.
b. The shell doesn't exit in posix mode if the eval builtin gets a parse
error when run by the command builtin.
c. Fixed a bug that caused a shell comment in an alias to not find the end
of the alias properly.
d. Reverted a change from April, 2018 that caused strings containing
backslashes to be flagged as glob patterns.
2. Changes to Readline
3. New Features in Bash
4. New Features in Readline
------------------------------------------------------------------------------
This document details the changes between this version, bash-5.0-rc1, and
the previous version, bash-5.0-beta2.
1. Changes to Bash
a. Fix to initial word completion detection code.
b. Fixed a bug that caused issues with assignment statements containing ^A in
the value assigned when IFS contains ^A.
c. Added a fallback to fnmatch() when strcoll can't correctly deal with
bracket expression character equivalence classes.
d. Fixed a bug that caused $BASH_COMMAND to contain the trap handler command
when running a trap handler containing [[ or (( commands.
e. Fixed a bug that caused nameref assignments in the temporary environment
to potentially create variables with invalid names.
f. Fixed a bug that caused `local -' to turn off alias expansion in scripts.
g. Fixed a parser issue with a command string containing EOF after an invalid
command as an argument to a special builtin not causing a posix-mode shell
to exit.
h. Made a slight change to the FNV-1 string hash algorithm used for associative
arrays (corrected the initial seed).
2. Changes to Readline
3. New Features in Bash
a. The `select' command now supports command forms without a word list
following `in'.
4. New Features in Readline
------------------------------------------------------------------------------
This document details the changes between this version, bash-5.0-beta2, and
the previous version, bash-5.0-beta.
......
......@@ -3604,7 +3604,7 @@ pathexp.c
does not end in a backslash, we need to return true. Fixes bug
reported by Robert Elz <kre@bmunnari.OZ.AU>
lib/glob/gm_loop.c
lib/glob/glob_loop.c
- INTERNAL_GLOB_PATTERN_P: same change to return TRUE for a backslash
that doesn't end the pattern
......@@ -4762,3 +4762,206 @@ bashline.c
from Luca Boccassi <bluca@debian.org>
[bash-5.0-beta2 frozen]
11/27
-----
bashline.c
- attempt_shell_completion: better fix for problems with fix from
11/16. Report and fix from Tom Ryder <tom@sanctum.geek.nz>
expr.c
- expr_skipsubscript: fix return type. Report and fix from
Andreas Schwab <schwab@linux-m68k.org>
11/29
-----
subst.c
- quote_escapes_internal: refactored quote_escapes into a function
that takes an additional flag saying whether or not we are going
to split the result. If we are not, and CTLESC is in IFS, we quote
the CTLESC (ditto for CTLNUL) to prevent it being removed when the
string is dequoted.
- quote_escapes: call quote_escapes_internal with FLAGS == 0
- quote_rhs: new function, calls quote_escapes with FLAGS == PF_NOSPLIT2
so that a CTLESC will be quoted if CTLESC is in $IFS
- parameter_brace_expand_word: call quote_rhs on the value of a variable
if PFLAGS includes PF_ASSIGNRHS, indicating that we will not be
splitting the word, but we will be dequoting it. Fixes bug reported
by Martijn Dekker <martijn@inlv.org>
- param_expand: same change as for parameter_brace_expand_word
execute_cmd.c
- execute_in_subshell: if we are running a trap (running_trap > 0),
turn off the SIG_INPROGRESS and SIG_CHANGED flags for that signal
by calling run_trap_cleanup and reset running_trap to 0 (watch the
second part!). Tagged for bash-5.1.
11/30
-----
lib/readline/doc/rltech.texi
- rl_set_keymap_name: correct typo in the name; some updates to the
description that clarify usage. Report from <hirooih@gmail.com>
12/4
----
aclocal.m4
- BASH_FUNC_FNMATCH_EQUIV_FALLBACK: a test of whether fnmatch(3)
understands bracket equivalence classes ([=c=]) for characters
that collate with equal weights but are not identical
configure.ac,config.h.in
- call BASH_FUNC_FNMATCH_EQUIV_FALLBACK and define
FNMATCH_EQUIV_FALLBACK to 1 if it can be used for equivalence
classes
12/5
----
execute_cmd.c
- eval_arith_for_expr,execute_arith_command,execute_cond_command: make
sure running_trap == 0 before we reset the_printed_command_except_trap
Report from Peng Yu <pengyu.ut@gmail.com>
lib/glob/smatch.c
- _fnmatch_fallback_wc: new function, takes two wide characters c1 and
c2, converts them to a pattern ([[=c2=]]) and a string (c1) for
fnmatch to determine whether or not they are members of the same
equivalence class
- collequiv_wc: call _fnmatch_fallback_wc if rangecmp_wc returns
non-zero if FNMATCH_EQUIV_FALLBACK is defined, so we know that
fnmatch understands equivalence classes. Another Posix test suite
issue from Martin Rehak <martin.rehak@oracle.com>
12/6
----
redir.c
- add missing cases to switch statements to shut up gcc
12/7
----
builtins/set.def
- find_minus_o_option: new helper function, returns index into
o_options given option name
- minus_o_option_value,set_minus_o_option: use find_minus_o_option
general.c
- new table of variables (currently all shopt options) that are
modified by going into and out of posix mode; num_posix_options()
returns the number of variables
- get_posix_options: fill in a bitmap passed as an argument (or return
a new one) of values of posix-mode-modified variables in the table
- set_posix_options: set values of posix-mode-modified variables from
the table using the passed bitmap for values
builtins/set.def
- get_current_options: make the bitmap large enough to hold the options
in the set table and the table of posix-mode-modified variables; call
get_posix_options to fill in those values after the values from the
o_options table
- set_current_options: call set_posix_options to reset the values of
the posix-mode-modified variables at the end of the bitmap, after
the o_options values. Fixes issue reported by PJ Eby
<pje@telecommunity.com>
12/9
----
parse.y
- select_command: add two additional productions to support select
commands without a word_list following the `in'. Fixes omission
reported by Martijn Dekker <martijn@inlv.org>
12/11
-----
variables.c
- assign_in_env: don't allow namerefs in temporary environment
assignments to create variables with invalid names for export. Fixes
bug reported by Grisha Levit <grishalevit@gmail.com>
12/14
-----
parse.y
- don't change last_command_exit_value in the 'error yacc_EOF' production
if the parser sets it to something non-zero; just make sure it
indicates an error. Fixes problem with unexpected EOF in eval
reported by Martijn Dekker <martijn@inlv.org>
12/17
-----
expr.c
- exp2 -> expmuldiv
lib/sh/smatch.c
- fnmatch: add extern declaration if FNMATCH_EQUIV_FALLBACK is being
used
hashlib.c
- hash_string: add FNV offset as initial value for hash instead of
starting at 0, changes hash for associative arrays and requires a
bunch of changes to the "right" test suite files
variables.c
- rseed: make it explicitly 32 bits; that's all we're interested in
anyway
12/18
-----
variables.c
- brand: add some comments, make the constants explicitly 32 bits;
use signed 32-bit values for the intermediate calculations. The
algorithm is still minstd
[bash-5.0-rc1 frozen]
12/21
-----
doc/bash.1
- }1: remove macro definition; it's outlived its bugfix purpose.
Report from Derek Schrock <dereks@lifeofadishwasher.com>
12/22
-----
subst.c
- expand_arith_string: set W_NOTILDE in the flags so we don't perform
tilde expansion at all, even for the previously-special-case array
subscript expansion. Report from Bize Ma <binaryzebra@gmail.com>
- expand_word_internal: take out Q_ARRAYSUB check for tilde expansion
12/26
-----
builtins/evalstring.c
- parse_and_execute: if the eval builtin gets a parser error while
parsing a string in posix mode, don't exit the shell if the eval
was run by the command builtin. report from Martijn Dekker
<martijn@inlv.org>
examples/loadables/{basename,dirname}.c
- dirname_builtin: skip over any `--' ending the options. Report from
Peng Yu <pengyu.ut@gmail.com>
12/27
-----
examples/loadables/mkdir.c
- make_path: add argument noting whether or not the user specified -m;
only attempt the chmod on an existing directory if the user did so
- make_path: when creating intermediate directories, perform the
mkdir (path, 0) and chmod separately as the posix text recommends
12/28
-----
parser.h
- PST_COMMENT: new state, set when the shell is reading characters
until newline as part of comment processing
parse.y
- shell_getc: don't return a space at the end of a token if the parser
is consuming a comment. Fixes bug reported by Harald van Dijk
<harald@gigawatt.nl>
12/31
-----
lib/glob/glob_loop.c
- INTERNAL_GLOB_PATTERN_P: revert change from 4/27 that makes this
function return non-zero for a backslash in the string. Based on a
report from Tom Ryder <tom@sanctum.geek.nz>
[bash-5.0 frozen]
......@@ -941,7 +941,6 @@ tests/cond-regexp2.sub f
tests/cond-regexp3.sub f
tests/coproc.tests f
tests/coproc.right f
tests/coproc1.sub f
tests/cprint.tests f
tests/cprint.right f
tests/dbg-support.right f
......@@ -991,6 +990,7 @@ tests/errors4.sub f
tests/errors5.sub f
tests/errors6.sub f
tests/errors7.sub f
tests/errors8.sub f
tests/execscript f
tests/exec.right f
tests/exec1.sub f 755
......@@ -1059,6 +1059,7 @@ tests/glob.tests f
tests/glob1.sub f
tests/glob2.sub f
tests/glob3.sub f
tests/glob4.sub f
tests/glob.right f
tests/globstar.tests f
tests/globstar.right f
......
......@@ -4223,3 +4223,40 @@ main(int c, char **v)
[Define if you have a working sbrk function.])
fi
])
AC_DEFUN(BASH_FUNC_FNMATCH_EQUIV_FALLBACK,
[AC_MSG_CHECKING(whether fnmatch can be used to check bracket equivalence classes)
AC_CACHE_VAL(bash_cv_fnmatch_equiv_fallback,
[AC_TRY_RUN([
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <fnmatch.h>
#include <locale.h>
char *pattern = "[[=a=]]";
/* char *string = "ä"; */
unsigned char string[4] = { '\xc3', '\xa4', '\0' };
int
main (int c, char **v)
{
setlocale (LC_ALL, "de_DE.UTF-8");
if (fnmatch (pattern, (const char *)string, 0) != FNM_NOMATCH)
exit (0);
exit (1);
}
], bash_cv_fnmatch_equiv_fallback=yes, bash_cv_fnmatch_equiv_fallback=no,
[AC_MSG_WARN(cannot check fnmatch if cross compiling -- defaulting to no)
bash_cv_fnmatch_equiv_fallback=no]
)])
AC_MSG_RESULT($bash_cv_fnmatch_equiv_fallback)
if test "$bash_cv_fnmatch_equiv_fallback" = "yes" ; then
bash_cv_fnmatch_equiv_value=1
else
bash_cv_fnmatch_equiv_value=0
fi
AC_DEFINE_UNQUOTED([FNMATCH_EQUIV_FALLBACK], [$bash_cv_fnmatch_equiv_value], [Whether fnmatch can be used for bracket equivalence classes])
])
......@@ -1583,7 +1583,8 @@ attempt_shell_completion (text, start, end)
/* command completion if programmable completion fails */
/* If we have a completion for the initial word, we can prefer that */
in_command_position = s == start && (iw_compspec || STREQ (n, text)); /* XXX */
foundcs = foundcs && (iw_compspec == 0);
if (iw_compspec && in_command_position)
foundcs = 0;
}
/* empty command name following command separator */
else if (s >= e && n[0] == '\0' && text[0] == '\0' && start > 0 &&
......
......@@ -38,7 +38,7 @@ Options:
without any specific completion defined
-E apply the completions and actions to "empty" commands --
completion attempted on a blank line
-I apply the completions and actions to the intial (usually the
-I apply the completions and actions to the initial (usually the
command) word
When completion is attempted, the actions are applied in the order the
......
This file is echo.def, from which is created echo.c.
It implements the builtin "echo" in Bash.
Copyright (C) 1987-2016 Free Software Foundation, Inc.
Copyright (C) 1987-2018 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
......@@ -62,6 +62,10 @@ Options:
0 to 3 octal digits
\xHH the eight-bit character whose value is HH (hexadecimal). HH
can be one or two hex digits
\uHHHH the Unicode character whose value is the hexadecimal value HHHH.
HHHH can be one to four hex digits.
\UHHHHHHHH the Unicode character whose value is the hexadecimal value
HHHHHHHH. HHHHHHHH can be one to eight hex digits.
Exit Status:
Returns success unless a write error occurs.
......
......@@ -448,11 +448,11 @@ parse_and_execute (string, from_file, flags)
}
else
{
last_result = EXECUTION_FAILURE;
last_result = EX_BADUSAGE; /* was EXECUTION_FAILURE */
if (interactive_shell == 0 && this_shell_builtin &&
(this_shell_builtin == source_builtin || this_shell_builtin == eval_builtin) &&
last_command_exit_value == EX_BADSYNTAX && posixly_correct)
last_command_exit_value == EX_BADSYNTAX && posixly_correct && executing_command_builtin == 0)
{
should_jump_to_top_level = 1;
code = ERREXIT;
......
This file is set.def, from which is created set.c.
It implements the "set" and "unset" builtins in Bash.
Copyright (C) 1987-2015 Free Software Foundation, Inc.
Copyright (C) 1987-2018 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
......@@ -154,6 +154,8 @@ $END
typedef int setopt_set_func_t __P((int, char *));
typedef int setopt_get_func_t __P((char *));
static int find_minus_o_option __P((char *));
static void print_minus_o_option __P((char *, int, int));
static void print_all_shell_variables __P((void));
......@@ -242,6 +244,18 @@ const struct {
((o_options[i].set_func) ? (*o_options[i].set_func) (onoff, name) \
: (*o_options[i].variable = (onoff == FLAG_ON)))
static int
find_minus_o_option (name)
char *name;
{
register int i;
for (i = 0; o_options[i].name; i++)
if (STREQ (name, o_options[i].name))
return i;
return -1;
}
int
minus_o_option_value (name)
char *name;
......@@ -249,21 +263,17 @@ minus_o_option_value (name)
register int i;
int *on_or_off;
for (i = 0; o_options[i].name; i++)
i = find_minus_o_option (name);
if (i < 0)
return (-1);
if (o_options[i].letter)
{
if (STREQ (name, o_options[i].name))
{
if (o_options[i].letter)
{
on_or_off = find_flag (o_options[i].letter);
return ((on_or_off == FLAG_UNKNOWN) ? -1 : *on_or_off);
}
else
return (GET_BINARY_O_OPTION_VALUE (i, name));
}
on_or_off = find_flag (o_options[i].letter);
return ((on_or_off == FLAG_UNKNOWN) ? -1 : *on_or_off);
}
return (-1);
else
return (GET_BINARY_O_OPTION_VALUE (i, name));
}
#define MINUS_O_FORMAT "%-15s\t%s\n"
......@@ -323,9 +333,12 @@ char *
get_current_options ()
{
char *temp;
int i;
int i, posixopts;
temp = (char *)xmalloc (1 + N_O_OPTIONS);
posixopts = num_posix_options (); /* shopts modified by posix mode */
/* Make the buffer big enough to hold the set -o options and the shopt
options modified by posix mode. */
temp = (char *)xmalloc (1 + N_O_OPTIONS + posixopts);
for (i = 0; o_options[i].name; i++)
{
if (o_options[i].letter)
......@@ -333,7 +346,11 @@ get_current_options ()
else
temp[i] = GET_BINARY_O_OPTION_VALUE (i, o_options[i].name);
}
temp[i] = '\0';
/* Add the shell options that are modified by posix mode to the end of the
bitmap. They will be handled in set_current_options() */
get_posix_options (temp+i);
temp[i+posixopts] = '\0';
return (temp);
}
......@@ -345,6 +362,7 @@ set_current_options (bitmap)
if (bitmap == 0)
return;
for (i = 0; o_options[i].name; i++)
{
if (o_options[i].letter)
......@@ -352,6 +370,9 @@ set_current_options (bitmap)
else
SET_BINARY_O_OPTION_VALUE (i, bitmap[i] ? FLAG_ON : FLAG_OFF, o_options[i].name);
}
/* Now reset the variables changed by posix mode */
set_posix_options (bitmap+i);
}
static int
......@@ -451,32 +472,29 @@ set_minus_o_option (on_or_off, option_name)
{
register int i;
for (i = 0; o_options[i].name; i++)
i = find_minus_o_option (option_name);
if (i < 0)
{
if (STREQ (option_name, o_options[i].name))
{
if (o_options[i].letter == 0)
{
previous_option_value = GET_BINARY_O_OPTION_VALUE (i, o_options[i].name);
SET_BINARY_O_OPTION_VALUE (i, on_or_off, option_name);
return (EXECUTION_SUCCESS);
}
else
{
if ((previous_option_value = change_flag (o_options[i].letter, on_or_off)) == FLAG_ERROR)
{
sh_invalidoptname (option_name);
return (EXECUTION_FAILURE);
}
else
return (EXECUTION_SUCCESS);
}
sh_invalidoptname (option_name);
return (EX_USAGE);
}
if (o_options[i].letter == 0)
{
previous_option_value = GET_BINARY_O_OPTION_VALUE (i, o_options[i].name);
SET_BINARY_O_OPTION_VALUE (i, on_or_off, option_name);
return (EXECUTION_SUCCESS);
}
else
{
if ((previous_option_value = change_flag (o_options[i].letter, on_or_off)) == FLAG_ERROR)
{
sh_invalidoptname (option_name);
return (EXECUTION_FAILURE);
}
else
return (EXECUTION_SUCCESS);
}
sh_invalidoptname (option_name);
return (EX_USAGE);
}
static void
......
......@@ -612,6 +612,9 @@
/* Define if you have the fnmatch function. */
#undef HAVE_FNMATCH
/* Can fnmatch be used as a fallback to match [=equiv=] with collation weights? */
#undef FNMATCH_EQUIV_FALLBACK
/* Define if you have the fpurge/__fpurge function. */
#undef HAVE_FPURGE
#undef HAVE___FPURGE
......
#! /bin/sh
# From configure.ac for Bash 5.0, version 5.003.
# From configure.ac for Bash 5.0, version 5.005.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for bash 5.0-beta2.
# Generated by GNU Autoconf 2.69 for bash 5.0-release.
#
# Report bugs to <bug-bash@gnu.org>.
#
......@@ -581,8 +581,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='bash'
PACKAGE_TARNAME='bash'
PACKAGE_VERSION='5.0-beta2'
PACKAGE_STRING='bash 5.0-beta2'
PACKAGE_VERSION='5.0-release'
PACKAGE_STRING='bash 5.0-release'
PACKAGE_BUGREPORT='bug-bash@gnu.org'
PACKAGE_URL=''
......@@ -1394,7 +1394,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures bash 5.0-beta2 to adapt to many kinds of systems.
\`configure' configures bash 5.0-release to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1459,7 +1459,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of bash 5.0-beta2:";;
short | recursive ) echo "Configuration of bash 5.0-release:";;
esac
cat <<\_ACEOF
......@@ -1655,7 +1655,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
bash configure 5.0-beta2
bash configure 5.0-release
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
......@@ -2364,7 +2364,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by bash $as_me 5.0-beta2, which was
It was created by bash $as_me 5.0-release, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
......@@ -2759,7 +2759,7 @@ ac_config_headers="$ac_config_headers config.h"
BASHVERS=5.0
RELSTATUS=beta2
RELSTATUS=release
case "$RELSTATUS" in
alp*|bet*|dev*|rc*|releng*|maint*) DEBUG='-DDEBUG' MALLOC_DEBUG='-DMALLOC_DEBUG' ;;
......@@ -4938,12 +4938,6 @@ fi
CFLAGS=${CFLAGS-"$AUTO_CFLAGS"}
# LDFLAGS=${LDFLAGS="$AUTO_LDFLAGS"} # XXX
# turn off paren warnings in gcc
if test "$GCC" = yes # && test -n "$DEBUG"
then
CFLAGS="$CFLAGS -Wno-parentheses -Wno-format-security"
fi
if test "$opt_profiling" = "yes"; then
PROFILE_FLAGS=-pg
case "$host_os" in
......@@ -15275,6 +15269,67 @@ $as_echo "#define HAVE_PRINTF_A_FORMAT 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fnmatch can be used to check bracket equivalence classes" >&5
$as_echo_n "checking whether fnmatch can be used to check bracket equivalence classes... " >&6; }
if ${bash_cv_fnmatch_equiv_fallback+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "$cross_compiling" = yes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot check fnmatch if cross compiling -- defaulting to no" >&5
$as_echo "$as_me: WARNING: cannot check fnmatch if cross compiling -- defaulting to no" >&2;}
bash_cv_fnmatch_equiv_fallback=no
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <fnmatch.h>
#include <locale.h>
char *pattern = "[[=a=]]";
/* char *string = "ä"; */
unsigned char string[4] = { '\xc3', '\xa4', '\0' };
int
main (int c, char **v)
{
setlocale (LC_ALL, "de_DE.UTF-8");
if (fnmatch (pattern, (const char *)string, 0) != FNM_NOMATCH)
exit (0);
exit (1);
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
bash_cv_fnmatch_equiv_fallback=yes
else
bash_cv_fnmatch_equiv_fallback=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_fnmatch_equiv_fallback" >&5
$as_echo "$bash_cv_fnmatch_equiv_fallback" >&6; }
if test "$bash_cv_fnmatch_equiv_fallback" = "yes" ; then
bash_cv_fnmatch_equiv_value=1
else
bash_cv_fnmatch_equiv_value=0
fi
cat >>confdefs.h <<_ACEOF
#define FNMATCH_EQUIV_FALLBACK $bash_cv_fnmatch_equiv_value
_ACEOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if signal handlers must be reinstalled when invoked" >&5
......@@ -16301,6 +16356,16 @@ m88k-motorola-sysv3) LOCAL_CFLAGS=-DWAITPID_BROKEN ;;
mips-pyramid-sysv4) LOCAL_CFLAGS=-Xa ;;
esac