[glib/wip/oholy/gio-completion: 1/3] gio: Fix completion of URIs without hostname part



commit 3a1492ec4f3399f16a47733feffc2003287f9e4f
Author: Ondrej Holy <oholy redhat com>
Date:   Thu Oct 3 14:44:57 2019 +0200

    gio: Fix completion of URIs without hostname part
    
    Currently, "gio list file:///h<tab>" doesn't complete "file:///home"
    because the result of "dirname file:///h" is not "file:///" but "file:/",
    which breaks the consequent logic. Let's subtract basename from the
    path in order to workaround this issue.

 gio/completion/gio | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/gio/completion/gio b/gio/completion/gio
index 86a90e585..1e6ef7e8d 100644
--- a/gio/completion/gio
+++ b/gio/completion/gio
@@ -43,7 +43,8 @@ __gio_location() {
     if [[ $cur =~ "/"$ ]]; then
         dir="$cur"
     elif [[ $cur =~ "/" ]]; then
-        dir="$(dirname "$cur")/"
+        # Subtract basename because dirname cmd doesn't work well with schemes
+        dir=${cur%$(basename "$cur")}
     fi
 
     # List daemon mounts, just if dir is not specified, or looks like scheme


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]