]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20190405 snapshot
authorChet Ramey <chet.ramey@case.edu>
Mon, 8 Apr 2019 13:08:27 +0000 (09:08 -0400)
committerChet Ramey <chet.ramey@case.edu>
Mon, 8 Apr 2019 13:08:27 +0000 (09:08 -0400)
CWRU/CWRU.chlog
bashline.c
findcmd.c
lib/readline/doc/rluser.texi
lib/readline/histfile.c

index 11073450f13bf5dfd8f01da7242c568844184e1f..e70b7195ae0435c6230abe89cae8f7b360064800 100644 (file)
@@ -5704,3 +5704,10 @@ builtins/common.c,builtins/printf.def
 
 builtins/read.def
        - bind_read_variable: now uses builtin_bind_variable
+
+                                   4/4
+                                   ---
+lib/readline/histfile.c
+       - 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>
index 0e25017143ced59aac34984c977efdb5f623202f..da9a02eae9a4691892f3a70330d8ca1df85ee744 100644 (file)
@@ -3766,7 +3766,7 @@ completion_glob_pattern (string)
 
        case '\\':
          if (*string++ == 0)
-           return (0);           
+           return (0);
        }
 
       /* Advance one fewer byte than an entire multibyte character to
index c3f00a408f4a0c6e59d12f0b458e296f4f3e6c7c..6cc4455eff8363881e09c66751d039d2f6dab49d 100644 (file)
--- a/findcmd.c
+++ b/findcmd.c
@@ -397,6 +397,16 @@ search_for_command (pathname, flags)
              if (st & FS_EXECABLE)
                phash_insert ((char *)pathname, command, dot_found_in_search, 1);
            }
+#if 0  /* TAG:bash-5.1 */
+         /* If we're in posix mode, don't add files without the execute bit
+            to the hash table. */
+         else if (posixly_correct)
+           {
+             st = file_status (command);
+             if (st & FS_EXECABLE)
+               phash_insert ((char *)pathname, command, dot_found_in_search, 1);
+           }
+#endif
          else
            phash_insert ((char *)pathname, command, dot_found_in_search, 1);
        }
index 9b025e4711d1d6a118ae1c5da0db6a552d39ee98..bbe41e1e3ecd986a831ccc78edaa739f3dac9923 100644 (file)
@@ -2370,7 +2370,7 @@ character to the directory name, in case we want to append to it.
 The @option{-o bashdefault} option brings in the rest of the "Bash default"
 completions -- possible completion that Bash adds to the default Readline
 set.  These include things like command name completion, variable completion
-for words beginning with @samp{@{}, completions containing pathname
+for words beginning with @samp{$} or @samp{$@{}, completions containing pathname
 expansion patterns (@pxref{Filename Expansion}), and so on.
 
 Once installed using @code{complete}, @code{_comp_cd} will be called every
index a8a92aa3604a52216ff29a353e282482d80c4184..aa34fe2db4c7631a093602feaadfb4bbc5750219 100644 (file)
@@ -1,6 +1,6 @@
 /* histfile.c - functions to manipulate the history file. */
 
-/* Copyright (C) 1989-2018 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2019 Free Software Foundation, Inc.
 
    This file contains the GNU History Library (History), a set of
    routines for managing the text of previously typed lines.
 
 #endif /* HISTORY_USE_MMAP */
 
+#if defined(_WIN32)
+#  define WIN32_LEAN_AND_MEAN
+#  include <windows.h>
+#endif
+
 /* If we're compiling for __EMX__ (OS/2) or __CYGWIN__ (cygwin32 environment
    on win 95/98/nt), we want to open files with O_BINARY mode so that there
    is no \n -> \r\n conversion performed.  On other systems, we don't want to
@@ -138,6 +143,7 @@ static char *history_backupfile PARAMS((const char *));
 static char *history_tempfile PARAMS((const char *));
 static int histfile_backup PARAMS((const char *, const char *));
 static int histfile_restore PARAMS((const char *, const char *));
+static int history_rename PARAMS((const char *, const char *));
 
 /* Return the string that should be used in the place of this
    filename.  This only matters when you don't specify the
@@ -436,6 +442,18 @@ read_history_range (const char *filename, int from, int to)
   return (0);
 }
 
+/* We need a special version for WIN32 because Windows rename() refuses to
+   overwrite an existing file. */
+static int
+history_rename (const char *old, const char *new)
+{
+#if defined (_WIN32)
+  return (MoveFileEx (old, new, MOVEFILE_REPLACE_EXISTING) == 0 ? -1 : 0);
+#else
+  return (rename (old, new));
+#endif
+}
+
 /* Save FILENAME to BACK, handling case where FILENAME is a symlink
    (e.g., ~/.bash_history -> .histfiles/.bash_history.$HOSTNAME) */
 static int
@@ -449,10 +467,10 @@ histfile_backup (const char *filename, const char *back)
   if ((n = readlink (filename, linkbuf, sizeof (linkbuf) - 1)) > 0)
     {
       linkbuf[n] = '\0';
-      return (rename (linkbuf, back));
+      return (history_rename (linkbuf, back));
     }
 #endif
-  return (rename (filename, back));
+  return (history_rename (filename, back));
 }
 
 /* Restore ORIG from BACKUP handling case where ORIG is a symlink
@@ -468,10 +486,10 @@ histfile_restore (const char *backup, const char *orig)
   if ((n = readlink (orig, linkbuf, sizeof (linkbuf) - 1)) > 0)
     {
       linkbuf[n] = '\0';
-      return (rename (backup, linkbuf));
+      return (history_rename (backup, linkbuf));
     }
 #endif
-  return (rename (backup, orig));
+  return (history_rename (backup, orig));
 }
 
 /* Truncate the history file FNAME, leaving only LINES trailing lines.