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

Ville Skyttä ville.skytta at iki.fi
Sat Nov 28 10:51:19 UTC 2009


The following commit has been merged in the master branch:
commit 3a44188d52d0d430d9283725a69fdbe796bb741f
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Sat Nov 28 12:23:38 2009 +0200

    Fix scp completion for paths containing other backslash escaped chars besides spaces.

diff --git a/contrib/ssh b/contrib/ssh
index 8ab1fd1..73b9e4e 100644
--- a/contrib/ssh
+++ b/contrib/ssh
@@ -172,12 +172,14 @@ _scp()
 
     if [[ "$cur" == *:* ]]; then
         local IFS=$'\t\n'
+        # things we want to backslash escape
+        local esc="[][(){}<>\",:;^&\!$=?\`|\\ ']"
         # remove backslash escape from :
         cur=${cur/\\:/:}
         userhost=${cur%%?(\\):*}
         path=${cur#*:}
-        # unescape spaces
-        path=${path//\\\\ / }
+        # 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)
@@ -186,7 +188,7 @@ _scp()
         # add space at end of file names
         COMPREPLY=( $( ssh -o 'Batchmode yes' $userhost \
             command ls -aF1d "$path*" 2>/dev/null | \
-            sed -e "s/[][(){}<>\",:;^&\!$=?\`|\\ ']/\\\\\\\\\\\\&/g" \
+            sed -e "s/$esc/\\\\\\\\\\\\&/g" \
             -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
                 return 0
     fi

-- 
bash-completion



More information about the Bash-completion-commits mailing list