lineedit: filename completion on symlinks-to-dirs should add / too
This commit is contained in:
parent
a50a9b0fdf
commit
b520271f65
@ -517,8 +517,8 @@ static void exe_n_cwd_tab_completion(char *command, int type)
|
|||||||
|
|
||||||
for (i = 0; i < npaths; i++) {
|
for (i = 0; i < npaths; i++) {
|
||||||
dir = opendir(paths[i]);
|
dir = opendir(paths[i]);
|
||||||
if (!dir) /* Don't print an error */
|
if (!dir)
|
||||||
continue;
|
continue; /* don't print an error */
|
||||||
|
|
||||||
while ((next = readdir(dir)) != NULL) {
|
while ((next = readdir(dir)) != NULL) {
|
||||||
int len1;
|
int len1;
|
||||||
@ -528,14 +528,17 @@ static void exe_n_cwd_tab_completion(char *command, int type)
|
|||||||
if (strncmp(str_found, pfind, strlen(pfind)))
|
if (strncmp(str_found, pfind, strlen(pfind)))
|
||||||
continue;
|
continue;
|
||||||
/* not see .name without .match */
|
/* not see .name without .match */
|
||||||
if (*str_found == '.' && *pfind == 0) {
|
if (*str_found == '.' && *pfind == '\0') {
|
||||||
if (NOT_LONE_CHAR(paths[i], '/') || str_found[1])
|
if (NOT_LONE_CHAR(paths[i], '/') || str_found[1])
|
||||||
continue;
|
continue;
|
||||||
str_found = ""; /* only "/" */
|
str_found = ""; /* only "/" */
|
||||||
}
|
}
|
||||||
found = concat_path_file(paths[i], str_found);
|
found = concat_path_file(paths[i], str_found);
|
||||||
/* hmm, remover in progress? */
|
/* hmm, remove in progress? */
|
||||||
if (lstat(found, &st) < 0)
|
/* NB: stat() first so that we see is it a directory;
|
||||||
|
* but if that fails, use lstat() so that
|
||||||
|
* we still match dangling links */
|
||||||
|
if (stat(found, &st) && lstat(found, &st))
|
||||||
goto cont;
|
goto cont;
|
||||||
/* find with dirs? */
|
/* find with dirs? */
|
||||||
if (paths[i] != dirbuf)
|
if (paths[i] != dirbuf)
|
||||||
@ -547,7 +550,7 @@ static void exe_n_cwd_tab_completion(char *command, int type)
|
|||||||
found[len1+1] = '\0';
|
found[len1+1] = '\0';
|
||||||
|
|
||||||
if (S_ISDIR(st.st_mode)) {
|
if (S_ISDIR(st.st_mode)) {
|
||||||
/* name is directory */
|
/* name is a directory */
|
||||||
if (found[len1-1] != '/') {
|
if (found[len1-1] != '/') {
|
||||||
found[len1] = '/';
|
found[len1] = '/';
|
||||||
}
|
}
|
||||||
@ -565,7 +568,7 @@ static void exe_n_cwd_tab_completion(char *command, int type)
|
|||||||
closedir(dir);
|
closedir(dir);
|
||||||
}
|
}
|
||||||
if (paths != path1) {
|
if (paths != path1) {
|
||||||
free(paths[0]); /* allocated memory only in first member */
|
free(paths[0]); /* allocated memory is only in first member */
|
||||||
free(paths);
|
free(paths);
|
||||||
}
|
}
|
||||||
#undef dirbuf
|
#undef dirbuf
|
||||||
|
Loading…
Reference in New Issue
Block a user