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);
}
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
/* 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
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
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
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
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.