Fix scp completion for paths containing other backslash escaped chars besides spaces.
This commit is contained in:
parent
ff0f741dcf
commit
3a44188d52
@ -172,12 +172,14 @@ _scp()
|
|||||||
|
|
||||||
if [[ "$cur" == *:* ]]; then
|
if [[ "$cur" == *:* ]]; then
|
||||||
local IFS=$'\t\n'
|
local IFS=$'\t\n'
|
||||||
|
# things we want to backslash escape
|
||||||
|
local esc="[][(){}<>\",:;^&\!$=?\`|\\ ']"
|
||||||
# remove backslash escape from :
|
# remove backslash escape from :
|
||||||
cur=${cur/\\:/:}
|
cur=${cur/\\:/:}
|
||||||
userhost=${cur%%?(\\):*}
|
userhost=${cur%%?(\\):*}
|
||||||
path=${cur#*:}
|
path=${cur#*:}
|
||||||
# unescape spaces
|
# unescape (3 backslashes to 1 for chars we escaped)
|
||||||
path=${path//\\\\ / }
|
path=$( sed -e 's/\\\\\\\('$esc'\)/\\\1/g' <<<"$path" )
|
||||||
if [ -z "$path" ]; then
|
if [ -z "$path" ]; then
|
||||||
# default to home dir of specified user on remote host
|
# default to home dir of specified user on remote host
|
||||||
path=$(ssh -o 'Batchmode yes' $userhost pwd 2>/dev/null)
|
path=$(ssh -o 'Batchmode yes' $userhost pwd 2>/dev/null)
|
||||||
@ -186,7 +188,7 @@ _scp()
|
|||||||
# add space at end of file names
|
# add space at end of file names
|
||||||
COMPREPLY=( $( ssh -o 'Batchmode yes' $userhost \
|
COMPREPLY=( $( ssh -o 'Batchmode yes' $userhost \
|
||||||
command ls -aF1d "$path*" 2>/dev/null | \
|
command ls -aF1d "$path*" 2>/dev/null | \
|
||||||
sed -e "s/[][(){}<>\",:;^&\!$=?\`|\\ ']/\\\\\\\\\\\\&/g" \
|
sed -e "s/$esc/\\\\\\\\\\\\&/g" \
|
||||||
-e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
|
-e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user