commit bash-20150130 snapshot

This commit is contained in:
Chet Ramey
2015-02-09 11:02:29 -05:00
parent 6d7fc2d32d
commit f8b90b7bdd
5 changed files with 63 additions and 9 deletions
+9 -1
View File
@@ -7936,4 +7936,12 @@ lib/sh/casemod.c
single-byte input character (e.g., `i'). Fix for problem reported
by Stephane Chazelas <stephane.chazelas@gmail.com>
1/31
----
lib/readline/histfile.c
- history_truncate_file, history_do_write: if the first rename(2)
of the history file to the backup file fails, set the backup file
name to NULL to prevent any later attempts to restore the
original. Report from Jonathan Hankins <jhankins@homewood.k12.al.us>
- history_do_write: don't attempt to back up non-regular files.
Report from Jonathan Hankins <jhankins@homewood.k12.al.us>
+51 -5
View File
@@ -159,12 +159,29 @@ static char *
history_backupfile (filename)
const char *filename;
{
char *ret;
const char *fn;
char *ret, linkbuf[PATH_MAX+1];
size_t len;
ssize_t n;
struct stat fs;
len = strlen (filename);
fn = filename;
#if defined (HAVE_LSTAT)
if (lstat (filename, &fs) == 0 && S_ISLNK (fs.st_mode))
{
if ((n = readlink (filename, linkbuf, sizeof (linkbuf) - 1)) > 0)
{
linkbuf[n] = '\0';
fn = linkbuf;
}
else
fn = filename;
}
#endif
len = strlen (fn);
ret = xmalloc (len + 2);
strcpy (ret, filename);
strcpy (ret, fn);
ret[len] = '-';
ret[len+1] = '\0';
return ret;
@@ -329,6 +346,14 @@ read_history_range (filename, from, to)
return (0);
}
static int
backup (fn, back)
const char *fn;
const char *back;
{
return (rename (fn, back));
}
/* Truncate the history file FNAME, leaving only LINES trailing lines.
If FNAME is NULL, then use ~/.history. Returns 0 on success, errno
on failure. */
@@ -443,7 +468,14 @@ history_truncate_file (fname, lines)
bakname = history_backupfile (filename);
if (filename && bakname)
rename (filename, bakname);
{
/* XXX - need to check case where filename is a symlink */
if (rename (filename, bakname) < 0)
{
free (bakname); /* no backups if rename fails */
bakname = 0;
}
}
if ((file = open (filename, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0600)) != -1)
{
@@ -509,8 +541,22 @@ history_do_write (filename, nelements, overwrite)
bakname = (overwrite && output) ? history_backupfile (output) : 0;
exists = output ? (stat (output, &finfo) == 0) : 0;
/* Don't bother backing up if output doesn't exist yet */
if (exists == 0 || S_ISREG (finfo.st_mode) == 0)
{
free (bakname); /* no backups if not a regular file */
bakname = 0;
}
if (output && bakname)
rename (output, bakname);
{
/* XXX - need to check case where output is a symlink */
if (rename (output, bakname) < 0) /* no backups if rename fails */
{
free (bakname);
bakname = 0;
}
}
file = output ? open (output, mode, 0600) : -1;
rv = 0;
BIN
View File
Binary file not shown.
+2 -2
View File
@@ -5592,8 +5592,8 @@ read_comsub (fd, quoted, rflag)
if (c == 0)
{
#if 0
internal_warning ("read_comsub: ignored null byte in input");
#if 1
internal_warning ("command substitution: ignored null byte in input");
#endif
continue;
}
+1 -1
View File
@@ -1,4 +1,4 @@
BUILD_DIR=/usr/local/build/bash/bash-current
BUILD_DIR=/usr/local/build/chet/bash/bash-current
THIS_SH=$BUILD_DIR/bash
PATH=$PATH:$BUILD_DIR