Bugfix completing scp/sftp/ssh -F '' on bash-4
Use ${COMP_LINE:0:$COMP_POINT} instead of ${COMP_WORDS[@]} when searching for -F configfile in scp/sftp/ssh. This fixes a bug under bash-4 where completing: scp -F 'spaced conf' <TAB> causes `dequote' to yield errors: bash: eval: line 1: unexpected EOF while looking for matching `'' bash: eval: line 2: syntax error: unexpected end of file The bug occurs because of a bug in bash-4.0, where quoted words are split unintended, see: http://www.mail-archive.com/bug-bash@gnu.org/msg06095.html Also, using ${COMP_LINE:0:$COMP_POINT} is an improvement, because it takes the current cursor position into account.
This commit is contained in:
parent
18081e0d86
commit
d3187b6f35
@ -83,7 +83,7 @@ _ssh()
|
||||
-i -L -l -m -O -o -p -R -S -w' -- "$cur" ) )
|
||||
else
|
||||
# Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument
|
||||
set -- "${COMP_WORDS[@]}"
|
||||
set -- "${COMP_LINE:0:$COMP_POINT}"
|
||||
while [ $# -gt 0 ]; do
|
||||
if [ "${1:0:2}" = -F ]; then
|
||||
if [ ${#1} -gt 2 ]; then
|
||||
@ -138,7 +138,7 @@ _sftp()
|
||||
-- "$cur" ) )
|
||||
else
|
||||
# Search COMP_WORDS for '-F configfile' argument
|
||||
set -- "${COMP_WORDS[@]}"
|
||||
set -- "${COMP_LINE:0:$COMP_POINT}"
|
||||
while [ $# -gt 0 ]; do
|
||||
if [ "${1:0:2}" = -F ]; then
|
||||
if [ ${#1} -gt 2 ]; then
|
||||
@ -196,7 +196,7 @@ _scp()
|
||||
prefix=-F
|
||||
else
|
||||
# Search COMP_WORDS for '-F configfile' or '-Fconfigfile' argument
|
||||
set -- "${COMP_WORDS[@]}"
|
||||
set -- "${COMP_LINE:0:$COMP_POINT}"
|
||||
while [ $# -gt 0 ]; do
|
||||
if [ "${1:0:2}" = -F ]; then
|
||||
if [ ${#1} -gt 2 ]; then
|
||||
|
Loading…
x
Reference in New Issue
Block a user