feedback: do not list "." and ".." as possible <Tab><Tab> completions

The single dot serves no purpose, as the user is already there.  And
the double dot is reached more easily by typing a second dot first.

And anyway, . and .. are not shown when the user does not type a dot
first, so why show them when the user types a single dot followed by
<Tab><Tab>?  Most likely the user wants to see actual dot files, so
just show those.

This fixes https://savannah.gnu.org/bugs/?58619.
master
Benno Schulenberg 2020-06-19 09:54:57 +02:00
parent 287718cf8b
commit 6ce4e3ede8
1 changed files with 2 additions and 2 deletions

View File

@ -2451,8 +2451,8 @@ char **filename_completion(const char *buf, size_t length,
* and add each fitting one to the list of matches. */
while ((nextdir = readdir(dir)) != NULL) {
if (strncmp(nextdir->d_name, filename, filenamelen) == 0 &&
(*filename == '.' || (strcmp(nextdir->d_name, ".") != 0 &&
strcmp(nextdir->d_name, "..") != 0))) {
strcmp(nextdir->d_name, ".") != 0 &&
strcmp(nextdir->d_name, "..") != 0) {
char *fullname = charalloc(strlen(dirname) + strlen(nextdir->d_name) + 1);
sprintf(fullname, "%s%s", dirname, nextdir->d_name);