[Bash-completion-commits] [SCM] bash-completion branch, master, updated. b6434541ccae0d24dae6d567ac3a7f6b72235c5e

Ville Skyttä ville.skytta at iki.fi
Sat Dec 26 14:20:40 UTC 2009


The following commit has been merged in the master branch:
commit b6434541ccae0d24dae6d567ac3a7f6b72235c5e
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Sat Dec 26 16:20:14 2009 +0200

    Use scp remote/local completion functions in sshfs.

diff --git a/CHANGES b/CHANGES
index fe0c24b..842adfd 100644
--- a/CHANGES
+++ b/CHANGES
@@ -25,7 +25,7 @@ bash-completion (2.x)
   * Apply pine completion to alpine too.
   * Remove many unnecessary short option completions where long ones exist.
   * Improve chsh, configure, cvs, gkrellm, lftp, mdadm, modprobe, mplayer,
-    mysqladmin, rsync, screen, service, scp, ssh, update-alternatives,
+    mysqladmin, rsync, screen, service, scp, ssh, sshfs, update-alternatives,
     vncviewer, and general hostname completions.
   * Add abook and wtf completion, based on work by Raphaël Droz.
   * Add jarsigner, k3b, lftpget, pm-utils, pack200 and unpack200 completions.
diff --git a/contrib/sshfs b/contrib/sshfs
index 9301b63..78bf11d 100644
--- a/contrib/sshfs
+++ b/contrib/sshfs
@@ -1,6 +1,6 @@
 # sshfs(1) completion
 
-have sshfs && have ssh &&
+have sshfs &&
 _sshfs()
 {
     local cur userhost path
@@ -10,36 +10,16 @@ _sshfs()
 
     _expand || return 0
 
-    # things we want to backslash escape
-    local esc="[][(){}<>\",:;^&\!$=?\`|\\ ']"
-
-    if [[ "$cur" == *:* ]]; then
-        local IFS=$'\t\n'
-        # remove backslash escape from the first colon
-        cur=${cur/\\:/:}
-        userhost=${cur%%?(\\):*}
-        path=${cur#*:}
-        # unescape (3 backslashes to 1 for chars we escaped)
-        path=$( sed -e 's/\\\\\\\('$esc'\)/\\\1/g' <<<"$path" )
-        if [ -z "$path" ]; then
-            # default to home dir of specified user on remote host
-            path=$(ssh -o 'Batchmode yes' $userhost pwd 2>/dev/null)
-        fi
-        # escape spaces; remove executables, aliases, pipes and sockets;
-        # add space at end of file names
-        COMPREPLY=( $( ssh -o 'Batchmode yes' $userhost \
-            command ls -aF1d "$path*" 2>/dev/null | \
-            sed -e 's/'$esc'/\\\\\\&/g' -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
+    if [[ "$cur" == *:* ]] && type _scp_remote_files &>/dev/null ; then
+        _scp_remote_files -d
+        # unlike scp and rsync, sshfs works with 1 backslash instead of 3
+        COMPREPLY=( "${COMPREPLY[@]//\\\\\\/\\}" )
         return 0
     fi
 
     [[ "$cur" == */* ]] || _known_hosts_real -c -a "$cur"
 
-    # This approach is used instead of _filedir to get a space appended
-    # after local file/dir completions, and -o nospace retained for others.
-    local IFS=$'\t\n'
-    COMPREPLY=( "${COMPREPLY[@]}" $( command ls -aF1d $cur* 2>/dev/null | \
-        sed -e "s/$esc/\\\\&/g" -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
+    type _scp_local_files &>/dev/null && _scp_local_files -d
 
     return 0
 } &&

-- 
bash-completion



More information about the Bash-completion-commits mailing list