- history_rename: wrapper function for rename(2) to deal with the Win32
refusal to rename over an existing file; changed callers. Bug and fix
from <john.david.donoghue@gmail.com>
+
+ 4/8
+ ---
+builtins/trap.def
+ - display_traps,showtrap: take an additional int argument, that, if
+ non-zero, means to print a trap command for a signal whose disposition
+ is SIG_DFL
+ - trap_builtin: if the -p option is given, and posix mode is enabled,
+ pass the `show every signal' flag to display_traps so SIG_DFL signals
+ are displayed as `trap -- - <signal>'. From an austin-group
+ interpretation (1212) initiated by Robert Elz <kre@bmunnari.oz.au>.
+ Tagged for bash-5.1
+
+ 4/9
+ ---
+jobs.c
+ - list_one_job: printing one job counts as notifying the user about
+ it, so add a call to cleanup_dead_jobs like in the other job display
+ functions. Fixes https://savannah.gnu.org/support/?109667 reported
+ by "Brian K. White"
+
+ 4/10
+ ----
+redir.c
+ - HEREDOC_PIPESIZE: define to PIPESIZE if not defined, allow it to be
+ specified at build time; used in here_document_to_fd to determine
+ whether or not a pipe is used
+ - HEREDOC_PIPEMAX: allow build-time definition of the max heredoc size
+ that will be written to a pipe
+ - here_document_to_fd: if F_GETPIPE_SZ is defined (Linux), ensure that
+ the document is shorter than the possibly-dynamic max pipe size,
+ and fall back to the tempfile implementation if it is not
+ - HEREDOC_PARANOID: if this is defined to a non-zero value,
+ here_document_to_fd ensures that both file descriptors opened on
+ the temporary file refer to the same file
+
+lib/sh/zmapfd.c
+ - zmapfd: increased the default allocation sizes
+
+lib/sh/zcatfd.c
+ - zcatfd: increased the default allocation sizes
+
+input.c
+ - localbuf: increased the default buffer size for reads
+
+ 4/11
+ ----
+subst.c
+ - cond_expand_word: like expand_word_unsplit, we need to peform
+ quoted null character removal on both the LHS and RHS of the
+ operator, since we are not performing word splitting. Fixes bug
+ reported by Matt Whitlock in https://savannah.gnu.org/support/?109671
+
+ 4/12
+ ----
+jobs.c
+ - wait_for_background_pids: don't bother with the loop that waits for
+ and reaps all children of the shell in the case that it's inherited
+ some children it doesn't care about. Report from Daniel Kahn Gillmor
+ <dkg@fifthhorseman.net>
+
+ 4/14
+ ----
+subst.c
+ - command_substitute: add an unwind-protect to make sure the read end
+ of the pipe gets closed in the parent on a SIGINT that interrupts
+ the zread. Fixes fast SIGINT fd leak reported by Tycho Kirchner
+ <tychokirchner@mail.de>
+
+bashhist.c
+ - history_number: if enable_history_list is set (`set -o history' has
+ been executed), return the current history number even if we're
+ not currently saving commands in the history list
+ (remember_on_history == 0). Prompted by report from Paul Wise
+ <pabs3@bonedaddy.net>
/* bashhist.c -- bash interface to the GNU history library. */
-/* Copyright (C) 1993-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2019 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
history_number ()
{
using_history ();
- return (remember_on_history ? history_base + where_history () : 1);
+ return ((remember_on_history || enable_history_list) ? history_base + where_history () : 1);
}
static int
This file is trap.def, from which is created trap.c.
It implements the builtin "trap" in Bash.
-Copyright (C) 1987-2015 Free Software Foundation, Inc.
+Copyright (C) 1987-2019 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
#include "common.h"
#include "bashgetopt.h"
-static void showtrap __P((int));
-static int display_traps __P((WORD_LIST *));
+static void showtrap __P((int, int));
+static int display_traps __P((WORD_LIST *, int));
/* The trap command:
{
initialize_terminating_signals ();
get_all_original_signals ();
- return (sh_chkwrite (display_traps (list)));
+#if 0 /* TAG:bash-5.1 */
+ return (sh_chkwrite (display_traps (list, display && posixly_correct)));
+#else
+ return (sh_chkwrite (display_traps (list, 0)));
+#endif
}
else
{
}
static void
-showtrap (i)
- int i;
+showtrap (i, show_default)
+ int i, show_default;
{
char *t, *p, *sn;
p = trap_list[i];
if (p == (char *)DEFAULT_SIG && signal_is_hard_ignored (i) == 0)
- return;
+ {
+ if (show_default)
+ t = "-";
+ else
+ return;
+ }
else if (signal_is_hard_ignored (i))
t = (char *)NULL;
else
else
printf ("trap -- %s %s\n", t ? t : "''", sn);
- FREE (t);
+ if (show_default == 0)
+ FREE (t);
}
static int
-display_traps (list)
+display_traps (list, show_all)
WORD_LIST *list;
+ int show_all;
{
int result, i;
if (list == 0)
{
for (i = 0; i < BASH_NSIG; i++)
- showtrap (i);
+ showtrap (i, show_all);
return (EXECUTION_SUCCESS);
}
result = EXECUTION_FAILURE;
}
else
- showtrap (i);
+ showtrap (i, show_all);
}
return (result);
Copyright (C) 1988-2019 Free Software Foundation, Inc.
@end ignore
-@set LASTCHANGE Sun Mar 24 14:05:55 EDT 2019
+@set LASTCHANGE Fri Apr 12 16:27:08 EDT 2019
@set EDITION 5.0
@set VERSION 5.0
-@set UPDATED 24 March 2019
-@set UPDATED-MONTH March 2019
+@set UPDATED 12 April 2019
+@set UPDATED-MONTH April 2019
/* Functions to handle reading input on systems that don't restart read(2)
if a signal is received. */
-static char localbuf[128];
+static char localbuf[1024];
static int local_index = 0, local_bufused = 0;
/* Posix and USG systems do not guarantee to restart read () if it is
int format, ignore, job_index;
{
pretty_print_job (job_index, format, stdout);
+ cleanup_dead_jobs ();
}
void
r = wait_for (last_procsub_child->pid);
wait_procsubs ();
reap_procsubs ();
-#if 1
+#if 0
/* We don't want to wait indefinitely if we have stopped children. */
- /* XXX - should add a loop that goes through the list of process
- substitutions and waits for each proc in turn before this code. */
if (any_stopped == 0)
{
/* Check whether or not we have any unreaped children. */
}
}
+#if 0
/* When FLAGS includes GX_ALLDIRS, we want to skip a symlink
to a directory, since we will pick the directory up later. */
if (isdir == -2 && glob_testdir (subdir, 0) == 0)
free (subdir);
continue;
}
+#endif
/* XXX - should we even add this if it's not a directory? */
nextlink = (struct globval *) malloc (sizeof (struct globval));
the common GNU, Unix, and Linux commands -- are available as part of the
bash_completion project. This is installed by default on many GNU/Linux
distributions. Originally written by Ian Macdonald, the project now lives
-at @url{http://bash-completion.alioth.debian.org/}. There are ports for
+at @url{https://salsa.debian.org/debian/bash-completion}. There are ports for
other systems such as Solaris and Mac OS X.
An older version of the bash_completion package is distributed with bash
{
ssize_t nr;
int rval;
- char lbuf[128];
+ char lbuf[1024];
rval = 0;
while (1)
{
ssize_t nr;
int rval;
- char lbuf[128];
+ char lbuf[512];
char *result;
int rsize, rind;
rval = 0;
- result = (char *)xmalloc (rsize = 64);
+ result = (char *)xmalloc (rsize = 512);
rind = 0;
while (1)
return -1;
}
- RESIZE_MALLOCED_BUFFER (result, rind, nr, rsize, 128);
+ RESIZE_MALLOCED_BUFFER (result, rind, nr, rsize, 512);
memcpy (result+rind, lbuf, nr);
rind += nr;
}
# endif
#endif
+#ifndef HEREDOC_PIPESIZE
+# define HEREDOC_PIPESIZE PIPESIZE
+#endif
+
+#if defined (HEREDOC_PIPEMAX)
+# if HEREDOC_PIPESIZE > HEREDOC_PIPEMAX
+# define HEREDOC_PIPESIZE HEREDOC_PIPEMAX
+# endif
+#endif
+
#define SHELL_FD_BASE 10
int expanding_redir;
int r, fd, fd2, herepipe[2];
char *document;
size_t document_len;
+#if HEREDOC_PARANOID
+ struct stat st1, st2;
+#endif
/* Expand the here-document/here-string first and then decide what to do. */
document = heredoc_expand (redirectee, ri, &document_len);
return fd;
}
-#if defined (PIPESIZE)
+#if defined (HEREDOC_PIPESIZE)
/* Try to use a pipe internal to this process if the document is shorter
than the system's pipe capacity (computed at build time). We want to
write the entire document without write blocking. */
- if (document_len <= PIPESIZE)
+ if (document_len <= HEREDOC_PIPESIZE)
{
if (pipe (herepipe) < 0)
{
errno = r;
return (-1);
}
+
+#if defined (F_GETPIPE_SZ)
+ if (fcntl (herepipe[1], F_GETPIPE_SZ, 0) < document_len)
+ goto use_tempfile;
+#endif
+
r = heredoc_write (herepipe[1], document, document_len);
if (document != redirectee->word)
free (document);
}
#endif
+use_tempfile:
+
fd = sh_mktmpfd ("sh-thd", MT_USERANDOM|MT_USETMPDIR, &filename);
/* If we failed for some reason other than the file existing, abort */
return -1;
}
+#if HEREDOC_PARANOID
+ /* We can use same_file here to check whether or not fd and fd2 refer to
+ the same file, but we don't do that unless HEREDOC_PARANOID is defined. */
+ if (fstat (fd, &st1) < 0 || S_ISREG (st1.st_mode) == 0 ||
+ fstat (fd2, &st2) < 0 || S_ISREG (st2.st_mode) == 0 ||
+ same_file (filename, filename, &st1, &st2) == 0)
+ {
+ unlink (filename);
+ free (filename);
+ close (fd);
+ close (fd2);
+ errno = EEXIST;
+ return -1;
+ }
+#endif
+
close (fd);
if (unlink (filename) < 0)
{
this case, we quote the string specially for the globbing code. If
SPECIAL is 2, this is an rhs argument for the =~ operator, and should
be quoted appropriately for regcomp/regexec. The caller is responsible
- for removing the backslashes if the unquoted word is needed later. */
+ for removing the backslashes if the unquoted word is needed later. In
+ any case, since we don't perform word splitting, we need to do quoted
+ null character removal. */
char *
cond_expand_word (w, special)
WORD_DESC *w;
{
if (special == 0) /* LHS */
{
+ if (l->word)
+ word_list_remove_quoted_nulls (l);
dequote_list (l);
r = string_list (l);
}
}
else
{
+ int dummyfd;
+
#if defined (JOB_CONTROL) && defined (PGRP_PIPE)
close_pgrp_pipe ();
#endif /* JOB_CONTROL && PGRP_PIPE */
close (fildes[1]);
+ begin_unwind_frame ("read-comsub");
+ dummyfd = fildes[0];
+ add_unwind_protect (close, dummyfd);
+
tflag = 0;
istring = read_comsub (fildes[0], quoted, flags, &tflag);
close (fildes[0]);
+ discard_unwind_frame ("read-comsub");
current_command_subst_pid = pid;
last_command_exit_value = wait_for (pid);