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
#
# $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>
#
@ -2507,17 +2507,17 @@ _scp()
# 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/ /\\\\\\\ /g' -e 's/[*@|=]$//g' \
-e 's/[^\/]$/& /g' \
-e 's/\([&()<>;|]\)/\\&/g' ) )
command ls -aF1d "$path*" 2>/dev/null | \
sed -e 's/[][(){}<>",:;^&!$&=?`|\ ]/\\\\\\&/g' \
-e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
return 0
fi
[[ "$cur" == */* ]] || _known_hosts -c -a
COMPREPLY=( ${COMPREPLY[@]} $( command ls -aF1d $cur* \
2>/dev/null | sed -e 's/ /\\ /g' -e 's/[*@|=]$//g'\
-e 's/[^\/]$/& /g' -e 's/\([&()<>;|]\)/\\&/g' ) )
2>/dev/null | sed \
-e 's/[][(){}<>",:;^&!$&=?`|\ ]/\\&/g' \
-e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ) )
return 0
}
complete -F _scp $nospace scp