]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20150130 snapshot
authorChet Ramey <chet.ramey@case.edu>
Mon, 9 Feb 2015 16:02:29 +0000 (11:02 -0500)
committerChet Ramey <chet.ramey@case.edu>
Mon, 9 Feb 2015 16:02:29 +0000 (11:02 -0500)
CWRU/CWRU.chlog
lib/readline/histfile.c
po/._fr.po
subst.c
tests/RUN-ONE-TEST

index 1028fd39312c044c946897b632cc1003c2669eec..7d26ecbec8d996df0ef8bd14412bdaa1bf4422ee 100644 (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>
index aaab752562df5dccb833f909bc4a6558e6a66de5..efd8b33756fa9b10742e36ebd9863421575ad3e7 100644 (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;
index d2df2c787f16c920a98b9fafd939d6b8439fd0be..67b5381ad39da4f5a94a44424a68bc2a7260257e 100644 (file)
Binary files a/po/._fr.po and b/po/._fr.po differ
diff --git a/subst.c b/subst.c
index e2b57aa29debc80134b13fa4562024442f4714d1..2ad7d8ff31b399333ee65700d1621c5846038844 100644 (file)
--- a/subst.c
+++ b/subst.c
@@ -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;
        }
index 72ec06a2c1fd8dde92acea5e8ac773e35f1d061b..3efcf32d68e9722024b6ca9d67f9e81b2aa5ac04 100755 (executable)
@@ -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