[PATCH] fish: fix dir completion on filesystems w/o dirent.d_type (RHBZ#1153844).
On filesystems whose dirent.d_type is DT_UNKNOWN or some unknown value, manually check whether an entry is a directory, thus completing in the proper way. --- fish/destpaths.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fish/destpaths.c b/fish/destpaths.c index f224106..df1ec00 100644 --- a/fish/destpaths.c +++ b/fish/destpaths.c @@ -191,7 +191,13 @@ complete_dest_paths_generator (const char *text, int state) else { words = w; words[nr_words].name = p; - words[nr_words].is_dir = dirents->val[i].ftyp == 'd'; + if (dirents->val[i].ftyp == 'u' + || dirents->val[i].ftyp == '?') { + int is_dir = guestfs_is_dir_opts (g, words[nr_words].name, + GUESTFS_IS_DIR_OPTS_FOLLOWSYMLINKS, 1, -1); + words[nr_words].is_dir = is_dir; + } else + words[nr_words].is_dir = dirents->val[i].ftyp == 'd'; nr_words++; } } -- 1.9.3
When an entry is a symlink, check whether it points to a directory, so the entry for it can be completed correctly. --- fish/destpaths.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fish/destpaths.c b/fish/destpaths.c index df1ec00..d39d6c0 100644 --- a/fish/destpaths.c +++ b/fish/destpaths.c @@ -192,6 +192,7 @@ complete_dest_paths_generator (const char *text, int state) words = w; words[nr_words].name = p; if (dirents->val[i].ftyp == 'u' + || dirents->val[i].ftyp == 'l' || dirents->val[i].ftyp == '?') { int is_dir = guestfs_is_dir_opts (g, words[nr_words].name, GUESTFS_IS_DIR_OPTS_FOLLOWSYMLINKS, 1, -1); -- 1.9.3
On Fri, Oct 31, 2014 at 05:56:11PM +0100, Pino Toscano wrote:
When an entry is a symlink, check whether it points to a directory, so the entry for it can be completed correctly. --- fish/destpaths.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/fish/destpaths.c b/fish/destpaths.c index df1ec00..d39d6c0 100644 --- a/fish/destpaths.c +++ b/fish/destpaths.c @@ -192,6 +192,7 @@ complete_dest_paths_generator (const char *text, int state) words = w; words[nr_words].name = p; if (dirents->val[i].ftyp == 'u' + || dirents->val[i].ftyp == 'l' || dirents->val[i].ftyp == '?') { int is_dir = guestfs_is_dir_opts (g, words[nr_words].name, GUESTFS_IS_DIR_OPTS_FOLLOWSYMLINKS, 1, -1);
ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
On Fri, Oct 31, 2014 at 05:56:10PM +0100, Pino Toscano wrote:
On filesystems whose dirent.d_type is DT_UNKNOWN or some unknown value, manually check whether an entry is a directory, thus completing in the proper way.
Happens on Windows (NTFS) too, and it's also annoying there ...
--- fish/destpaths.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/fish/destpaths.c b/fish/destpaths.c index f224106..df1ec00 100644 --- a/fish/destpaths.c +++ b/fish/destpaths.c @@ -191,7 +191,13 @@ complete_dest_paths_generator (const char *text, int state) else { words = w; words[nr_words].name = p; - words[nr_words].is_dir = dirents->val[i].ftyp == 'd'; + if (dirents->val[i].ftyp == 'u' + || dirents->val[i].ftyp == '?') { + int is_dir = guestfs_is_dir_opts (g, words[nr_words].name, + GUESTFS_IS_DIR_OPTS_FOLLOWSYMLINKS, 1, -1);
Is it right to follow symlinks here I wonder?
+ words[nr_words].is_dir = is_dir; + } else + words[nr_words].is_dir = dirents->val[i].ftyp == 'd'; nr_words++; } } -- 1.9.3
Anyway, ACK. Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
On Friday 31 October 2014 17:07:24 Richard W.M. Jones wrote:
On Fri, Oct 31, 2014 at 05:56:10PM +0100, Pino Toscano wrote:
On filesystems whose dirent.d_type is DT_UNKNOWN or some unknown value, manually check whether an entry is a directory, thus completing in the proper way.
Happens on Windows (NTFS) too, and it's also annoying there ...
---
fish/destpaths.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/fish/destpaths.c b/fish/destpaths.c index f224106..df1ec00 100644 --- a/fish/destpaths.c +++ b/fish/destpaths.c @@ -191,7 +191,13 @@ complete_dest_paths_generator (const char *text, int state)> else {
words = w; words[nr_words].name = p;
- words[nr_words].is_dir = dirents->val[i].ftyp == 'd'; + if (dirents->val[i].ftyp == 'u' + || dirents->val[i].ftyp == '?') { + int is_dir = guestfs_is_dir_opts (g, words[nr_words].name, + GUESTFS_IS_DIR_OPTS_FOLLOWSYMLINKS, 1, -1); Is it right to follow symlinks here I wonder?
At least this is the behaviour bash seems to do: $ mkdir test $ touch test/file $ ln -s test link $ touch file $ ln -s file nondirlink $ vi t<TAB> -> test/ $ vi l<TAB> -> link/ $ vi f<TAB> -> file $ vi n<TAB> -> nondirlink -- Pino Toscano
participants (2)
-
Pino Toscano -
Richard W.M. Jones