Bash-4.4 distribution sources and documentation

This commit is contained in:
Chet Ramey 2016-09-15 16:59:08 -04:00
commit a0c0a00fc4
588 changed files with 130746 additions and 80164 deletions

View file

@ -2,7 +2,7 @@
* tmpfile.c - functions to create and safely open temp files for the shell.
*/
/* Copyright (C) 2000 Free Software Foundation, Inc.
/* Copyright (C) 2000-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@ -47,6 +47,11 @@ extern int errno;
#define DEFAULT_TMPDIR "." /* bogus default, should be changed */
#define DEFAULT_NAMEROOT "shtmp"
/* Use ANSI-C rand() interface if random(3) is not available */
#if !HAVE_RANDOM
#define random() rand()
#endif
extern pid_t dollar_dollar_pid;
static char *get_sys_tmpdir __P((void));
@ -109,6 +114,23 @@ get_tmpdir (flags)
return tdir;
}
static void
sh_seedrand ()
{
#if HAVE_RANDOM
int d;
static int seeded = 0;
if (seeded == 0)
{
struct timeval tv;
gettimeofday (&tv, NULL);
srandom (tv.tv_sec ^ tv.tv_usec ^ (getpid () << 16) ^ (uintptr_t)&d);
seeded = 1;
}
#endif
}
char *
sh_mktmpname (nameroot, flags)
char *nameroot;
@ -117,6 +139,7 @@ sh_mktmpname (nameroot, flags)
char *filename, *tdir, *lroot;
struct stat sb;
int r, tdlen;
static int seeded = 0;
filename = (char *)xmalloc (PATH_MAX + 1);
tdir = get_tmpdir (flags);
@ -132,6 +155,7 @@ sh_mktmpname (nameroot, flags)
filename = NULL;
}
#else /* !USE_MKTEMP */
sh_seedrand ();
while (1)
{
filenum = (filenum << 1) ^
@ -162,7 +186,7 @@ sh_mktmpfd (nameroot, flags, namep)
{
char *filename, *tdir, *lroot;
int fd, tdlen;
filename = (char *)xmalloc (PATH_MAX + 1);
tdir = get_tmpdir (flags);
tdlen = strlen (tdir);
@ -181,6 +205,7 @@ sh_mktmpfd (nameroot, flags, namep)
*namep = filename;
return fd;
#else /* !USE_MKSTEMP */
sh_seedrand ();
do
{
filenum = (filenum << 1) ^