Fix scp completion when filename contains shell metacharacters. (Patch from

Markus Wiederkehr <markus.wiederkehr@gmail.com>).
This commit is contained in:
ianmacd 2005-07-07 20:11:38 +00:00
parent 49ceb91daf
commit 75a3064ae1

View File

@ -1,6 +1,6 @@
# bash_completion - some programmable completion functions for bash 2.05b # bash_completion - some programmable completion functions for bash 2.05b
# #
# $Id: bash_completion,v 1.793 2005/07/07 22:07:00 ianmacd Exp $ # $Id: bash_completion,v 1.794 2005/07/07 22:11:38 ianmacd Exp $
# #
# Copyright (C) Ian Macdonald <ian@caliban.org> # Copyright (C) Ian Macdonald <ian@caliban.org>
# #
@ -2508,16 +2508,16 @@ _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' -e 's/[*@|=]$//g' \ sed -e 's/[][(){}<>",:;^&!$&=?`|\ ]/\\\\\\&/g' \
-e 's/[^\/]$/& /g' \ -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
-e 's/\([&()<>;|]\)/\\&/g' ) )
return 0 return 0
fi fi
[[ "$cur" == */* ]] || _known_hosts -c -a [[ "$cur" == */* ]] || _known_hosts -c -a
COMPREPLY=( ${COMPREPLY[@]} $( command ls -aF1d $cur* \ COMPREPLY=( ${COMPREPLY[@]} $( command ls -aF1d $cur* \
2>/dev/null | sed -e 's/ /\\ /g' -e 's/[*@|=]$//g'\ 2>/dev/null | sed \
-e 's/[^\/]$/& /g' -e 's/\([&()<>;|]\)/\\&/g' ) ) -e 's/[][(){}<>",:;^&!$&=?`|\ ]/\\&/g' \
-e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
return 0 return 0
} }
complete -F _scp $nospace scp complete -F _scp $nospace scp