From 0026a9cb0b2e4f2334d9aef04f615b8bf252ac04 Mon Sep 17 00:00:00 2001 From: ianmacd <> Date: Sun, 20 Oct 2002 20:11:21 +0000 Subject: [PATCH] - redirect stderr to /dev/null when performing remote path completion for scp - factor out the scp ls completion code into its own function, as we need to call this once remotely and once locally --- bash_completion | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/bash_completion b/bash_completion index 5f96bf89..7323fd9d 100644 --- a/bash_completion +++ b/bash_completion @@ -1,6 +1,6 @@ # bash_completion - some programmable completion functions for bash 2.05b # -# $Id: bash_completion,v 1.450 2002/10/20 06:56:41 ianmacd Exp $ +# $Id: bash_completion,v 1.451 2002/10/20 22:11:21 ianmacd Exp $ # # Copyright (C) Ian Macdonald # @@ -1918,6 +1918,14 @@ _ssh() } shopt -u hostcomplete && complete -F _ssh ssh slogin sftp +_scp_filedir() +{ + # do not indent last line of this function + ls -aF1d "$path*" 2>/dev/null | sed -e 's/ /\\\\\\\ /g' \ + -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' -e 's/\ +//g' +} + # scp(1) completion # _scp() @@ -1944,16 +1952,12 @@ _scp() # escape spaces; remove executables, aliases, pipes and sockets; # add space at end of file names; change newlines into spaces COMPREPLY=( $( ssh -o 'Batchmode yes' $userhost \ - ls -aF1d "$path*" | sed -e 's/ /\\\\\\\ /g' \ - -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' \ - -e 's/\ - //g' ) ) - + $(declare -f _scp_filedir | sed -e '1,2d; 5d'))) return 0 fi [[ "$cur" == */* ]] || _known_hosts -c -a - _filedir + COMPREPLY=( ${COMPREPLY[@]} $( _scp_filedir ) ) return 0 }