Reuse "esc" more in scp escaping.

This commit is contained in:
Ville Skyttä 2009-11-28 12:33:08 +02:00
parent 3a44188d52
commit c948a3d411

View File

@ -170,10 +170,11 @@ _scp()
_expand || return 0 _expand || return 0
if [[ "$cur" == *:* ]]; then
local IFS=$'\t\n'
# things we want to backslash escape # things we want to backslash escape
local esc="[][(){}<>\",:;^&\!$=?\`|\\ ']" local esc="[][(){}<>\",:;^&\!$=?\`|\\ ']"
if [[ "$cur" == *:* ]]; then
local IFS=$'\t\n'
# remove backslash escape from : # remove backslash escape from :
cur=${cur/\\:/:} cur=${cur/\\:/:}
userhost=${cur%%?(\\):*} userhost=${cur%%?(\\):*}
@ -218,7 +219,7 @@ _scp()
# after local file/dir completions, and -o nospace retained for others. # after local file/dir completions, and -o nospace retained for others.
local IFS=$'\t\n' local IFS=$'\t\n'
COMPREPLY=( "${COMPREPLY[@]}" $( command ls -aF1d $cur* 2>/dev/null | sed \ COMPREPLY=( "${COMPREPLY[@]}" $( command ls -aF1d $cur* 2>/dev/null | sed \
-e "s/[][(){}<>\",:;^&\!$=?\`|\\ ']/\\\\&/g" \ -e "s/$esc/\\\\&/g" \
-e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' -e "s/^/$prefix/") ) -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' -e "s/^/$prefix/") )
return 0 return 0