From: Chet Ramey Date: Mon, 8 Apr 2019 13:08:27 +0000 (-0400) Subject: commit bash-20190405 snapshot X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=03e4274f9bf733d78f1662bd4e81663dcd6f58af;p=thirdparty%2Fbash.git commit bash-20190405 snapshot --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 11073450f..e70b7195a 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -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 diff --git a/bashline.c b/bashline.c index 0e2501714..da9a02eae 100644 --- a/bashline.c +++ b/bashline.c @@ -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 diff --git a/findcmd.c b/findcmd.c index c3f00a408..6cc4455ef 100644 --- 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); } diff --git a/lib/readline/doc/rluser.texi b/lib/readline/doc/rluser.texi index 9b025e471..bbe41e1e3 100644 --- a/lib/readline/doc/rluser.texi +++ b/lib/readline/doc/rluser.texi @@ -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 diff --git a/lib/readline/histfile.c b/lib/readline/histfile.c index a8a92aa36..aa34fe2db 100644 --- a/lib/readline/histfile.c +++ b/lib/readline/histfile.c @@ -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. @@ -79,6 +79,11 @@ #endif /* HISTORY_USE_MMAP */ +#if defined(_WIN32) +# define WIN32_LEAN_AND_MEAN +# include +#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.