commit bash-20180209 snapshot

This commit is contained in:
Chet Ramey
2018-02-12 16:39:59 -05:00
parent 0275a139ab
commit fc132f73d1
10 changed files with 94 additions and 35 deletions
+28
View File
@@ -14927,3 +14927,31 @@ config-top.h
- DONT_REPORT_SIGPIPE: define, so non-interactive shells will no
longer print termination messages for child processes killed by
SIGTERM
2/6
---
lib/readline/text.c
- rl_insert: don't attempt to optimize typeahead if we are only reading
a fixed number of characters (rl_num_chars_to_read > 0)
redir.c
- redir_special_open: if the shell is restricted, return a
RESTRICTED_REDIRECT error for attempts to open /dev/tcp and /dev/udp
sockets. Inspired by report from Blake Burkhart <bburky@bburky.com>
- do_redirection_internal: if redir_open returns RESTRICTED_REDIRECT,
return that right away (instead of errno) so we can print a better
error message
2/11
----
jobs.c
- bgp_resize: fix problems with (pid_t) overflow when calculating new
size for table when js.c_childmax is near the limit of a pid_t
(e.g., 2**31 - 1 on a 32-bit system, or 2**63-1 on a system with
32-bit pid_t). Fixes hang reported by Natanael Copa
<ncopa@alpinelinux.org> based on his patch from 12/8.
- bgp_resize: cap max table size for bgpids at MAX_CHILD_MAX (32768)
include/typemax.h
- TYPE_MINIMUM, TYPE_MAXIMUM: updated definitions from coreutils-8.29,
silences some compiler warnings
+15 -15
View File
@@ -2133,7 +2133,7 @@ A value of
.I ignoreboth
is shorthand for \fIignorespace\fP and \fIignoredups\fP.
A value of
.IR erasedups
.I erasedups
causes all previous lines matching the current line to be removed from
the history list before that line is saved.
Any value not in the above list is ignored.
@@ -2794,7 +2794,7 @@ lexicographically between \fIx\fP and \fIy\fP, inclusive,
using the default C locale.
Note that both \fIx\fP and \fIy\fP must be of the same type.
When the increment is supplied, it is used as the difference between
each term. The default increment is 1 or -1 as appropriate.
each term. The default increment is 1 or \-1 as appropriate.
.PP
Brace expansion is performed before any other expansions,
and any characters special to other expansions are preserved
@@ -3042,7 +3042,7 @@ one space to avoid being confused with the \fB:-\fP expansion.
If \fIparameter\fP is \fB@\fP, the result is \fIlength\fP positional
parameters beginning at \fIoffset\fP.
A negative \fIoffset\fP is taken relative to one greater than the greatest
positional parameter, so an offset of -1 evaluates to the last positional
positional parameter, so an offset of \-1 evaluates to the last positional
parameter.
It is an expansion error if \fIlength\fP evaluates to a number less than
zero.
@@ -3439,7 +3439,7 @@ are ignored at the beginning and end of the
word, as long as the whitespace character is in the
value of
.SM
.BR IFS
.B IFS
(an
.SM
.B IFS
@@ -4423,7 +4423,7 @@ A shell variable that is null or unset evaluates to 0 when referenced
by name without using the parameter expansion syntax.
The value of a variable is evaluated as an arithmetic expression
when it is referenced, or when a variable which has been given the
\fIinteger\fP attribute using \fBdeclare -i\fP is assigned a value.
\fIinteger\fP attribute using \fBdeclare \-i\fP is assigned a value.
A null value evaluates to 0.
A shell variable need not have its \fIinteger\fP attribute
turned on to be used in an expression.
@@ -5633,13 +5633,13 @@ in emacs mode and to
.B #
in vi command mode.
.TP
.B completion\-display\-width (-1)
.B completion\-display\-width (\-1)
The number of screen columns used to display possible matches
when performing completion.
The value is ignored if it is less than 0 or greater than the terminal
screen width.
A value of 0 will cause matches to be displayed one per line.
The default value is -1.
The default value is \-1.
.TP
.B completion\-ignore\-case (Off)
If set to \fBOn\fP, readline performs filename matching and completion
@@ -6805,7 +6805,7 @@ of the setting of the \fBmark-symlinked\-directories\fP readline variable.
.PP
There is some support for dynamically modifying completions. This is
most useful when used in combination with a default completion specified
with \fBcomplete -D\fP.
with \fBcomplete \-D\fP.
It's possible for shell functions executed as completion
handlers to indicate that completion should be retried by returning an
exit status of 124. If a shell function returns 124, and changes
@@ -6962,7 +6962,7 @@ for information on setting and unsetting shell options.
.PP
The shell supports a history expansion feature that
is similar to the history expansion in
.BR csh.
.BR csh .
This section describes what syntax features are available. This
feature is enabled by default for interactive shells, and can be
disabled using the
@@ -8289,7 +8289,7 @@ with that string) or as a number (an index into the history list,
where a negative number is used as an offset from the current
command number). If
.I last
is not specified it is set to
is not specified, it is set to
the current command for listing (so that
.if n ``fc \-l \-10''
.if t \f(CWfc \-l \-10\fP
@@ -8298,7 +8298,7 @@ prints the last 10 commands) and to
otherwise.
If
.I first
is not specified it is set to the previous
is not specified, it is set to the previous
command for editing and \-16 for listing.
.sp 1
The
@@ -8802,7 +8802,7 @@ Exit a login shell.
Read lines from the standard input into the indexed array variable
.IR array ,
or from file descriptor
.IR fd
.I fd
if the
.B \-u
option is supplied.
@@ -8951,9 +8951,9 @@ causes \fBprintf\fP to output the date-time string resulting from using
\fIdatefmt\fP as a format string for \fIstrftime\fP(3).
The corresponding \fIargument\fP is an integer representing the number of
seconds since the epoch.
Two special argument values may be used: -1 represents the current
time, and -2 represents the time the shell was invoked.
If no argument is specified, conversion behaves as if -1 had been given.
Two special argument values may be used: \-1 represents the current
time, and \-2 represents the time the shell was invoked.
If no argument is specified, conversion behaves as if \-1 had been given.
This is an exception to the usual \fBprintf\fP behavior.
.PD
.PP
+10 -4
View File
@@ -261,6 +261,15 @@ send_pwd_to_eterm ()
free (f);
}
static void
execute_prompt_command ()
{
char *command_to_execute;
command_to_execute = get_string_value ("PROMPT_COMMAND");
if (command_to_execute)
execute_variable_command (command_to_execute, "PROMPT_COMMAND");
}
/* Call the YACC-generated parser and return the status of the parse.
Input is read from the current input stream (bash_input). yyparse
leaves the parsed command in the global variable GLOBAL_COMMAND.
@@ -269,7 +278,6 @@ int
parse_command ()
{
int r;
char *command_to_execute;
need_here_doc = 0;
run_pending_traps ();
@@ -282,9 +290,7 @@ parse_command ()
actually printed. */
if (interactive && bash_input.type != st_string && parser_expanding_alias() == 0)
{
command_to_execute = get_string_value ("PROMPT_COMMAND");
if (command_to_execute)
execute_variable_command (command_to_execute, "PROMPT_COMMAND");
execute_prompt_command ();
if (running_under_emacs == 2)
send_pwd_to_eterm (); /* Yuck */
+13 -4
View File
@@ -35,14 +35,23 @@
# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
#endif
#ifndef TYPE_SIGNED_MAGNITUDE
# define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
#endif
#ifndef TYPE_WIDTH
# define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
#endif
#ifndef TYPE_MINIMUM
# define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \
: (t) 0))
# define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
#endif
#ifndef TYPE_MAXIMUM
# define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
# define TYPE_MAXIMUM(t) \
((t) (! TYPE_SIGNED (t) \
? (t) -1 \
: ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1)))
#endif
#ifdef HAVE_LONG_LONG
+17 -6
View File
@@ -73,6 +73,8 @@
#include "execute_cmd.h"
#include "flags.h"
#include "typemax.h"
#include "builtins/builtext.h"
#include "builtins/common.h"
@@ -93,7 +95,7 @@ extern int killpg __P((pid_t, int));
#endif
#if !MAX_CHILD_MAX
# define MAX_CHILD_MAX 8192
# define MAX_CHILD_MAX 32768
#endif
#if !defined (DEBUG)
@@ -734,7 +736,7 @@ stop_pipeline (async, deferred)
static void
bgp_resize ()
{
ps_index_t nsize;
ps_index_t nsize, nsize_cur, nsize_max;
ps_index_t psi;
if (bgpids.nalloc == 0)
@@ -748,10 +750,19 @@ bgp_resize ()
else
nsize = bgpids.nalloc;
while (nsize < (ps_index_t)js.c_childmax)
nsize *= 2;
nsize_max = TYPE_MAXIMUM (ps_index_t);
nsize_cur = (ps_index_t)js.c_childmax;
if (nsize_cur < 0) /* overflow */
nsize_cur = MAX_CHILD_MAX;
if (bgpids.nalloc < js.c_childmax)
while (nsize > 0 && nsize < nsize_cur) /* > 0 should catch overflow */
nsize <<= 1;
if (nsize > nsize_max || nsize <= 0) /* overflow? */
nsize = nsize_max;
if (nsize > MAX_CHILD_MAX)
nsize = nsize_max = MAX_CHILD_MAX; /* hard cap */
if (bgpids.nalloc < nsize_cur && bgpids.nalloc < nsize_max)
{
bgpids.storage = (struct pidstat *)xrealloc (bgpids.storage, nsize * sizeof (struct pidstat));
@@ -768,7 +779,7 @@ bgp_resize ()
static ps_index_t
bgp_getindex ()
{
if (bgpids.nalloc < js.c_childmax || bgpids.head >= bgpids.nalloc)
if (bgpids.nalloc < (ps_index_t)js.c_childmax || bgpids.head >= bgpids.nalloc)
bgp_resize ();
pshash_delindex (bgpids.head); /* XXX - clear before reusing */
+2 -2
View File
@@ -149,8 +149,8 @@ Both @var{first} and
@var{last} may be specified as a string (to locate the most recent
command beginning with that string) or as a number (an index into the
history list, where a negative number is used as an offset from the
current command number). If @var{last} is not specified it is set to
@var{first}. If @var{first} is not specified it is set to the previous
current command number). If @var{last} is not specified, it is set to
@var{first}. If @var{first} is not specified, it is set to the previous
command for editing and @minus{}16 for listing. If the @option{-l} flag is
given, the commands are listed on standard output. The @option{-n} flag
suppresses the command numbers when listing. The @option{-r} flag
+2 -2
View File
@@ -378,13 +378,13 @@ in emacs mode and to
.B #
in vi command mode.
.TP
.B completion\-display\-width (-1)
.B completion\-display\-width (\-1)
The number of screen columns used to display possible matches
when performing completion.
The value is ignored if it is less than 0 or greater than the terminal
screen width.
A value of 0 will cause matches to be displayed one per line.
The default value is -1.
The default value is \-1.
.TP
.B completion\-ignore\-case (Off)
If set to \fBOn\fP, readline performs filename matching and completion
+1 -1
View File
@@ -242,7 +242,7 @@ int rl_erase_empty_line = 0;
/* Non-zero means to read only this many characters rather than up to a
character bound to accept-line. */
int rl_num_chars_to_read;
int rl_num_chars_to_read = 0;
/* Line buffer and maintenance. */
char *rl_line_buffer = (char *)NULL;
+1
View File
@@ -915,6 +915,7 @@ rl_insert (int count, int c)
x = 0;
n = (unsigned short)-2;
while (_rl_optimize_typeahead &&
rl_num_chars_to_read == 0 &&
(RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT) == 0) &&
_rl_pushed_input_available () == 0 &&
_rl_input_queued (0) &&
+5 -1
View File
@@ -578,6 +578,10 @@ redir_special_open (spec, filename, flags, mode, ri)
#if defined (NETWORK_REDIRECTIONS)
case RF_DEVTCP:
case RF_DEVUDP:
#if defined (RESTRICTED_SHELL)
if (restricted)
return (RESTRICTED_REDIRECT);
#endif
#if defined (HAVE_NETWORK)
fd = netopen (filename);
#else
@@ -850,7 +854,7 @@ do_redirection_internal (redirect, flags)
fd = redir_open (redirectee_word, redirect->flags, 0666, ri);
free (redirectee_word);
if (fd == NOCLOBBER_REDIRECT)
if (fd == NOCLOBBER_REDIRECT || fd == RESTRICTED_REDIRECT)
return (fd);
if (fd < 0)