Sophie

Sophie

distrib > * > 2008.0 > x86_64 > by-pkgid > 2e3acf97b6e69efb5b02391cf9118779 > files > 3

bash-completion-20060301-18mdv2008.0.src.rpm

--- bash_completion~	2005-07-12 21:13:02.000000000 +0200
+++ bash_completion	2005-07-13 10:34:59.242741468 +0200
@@ -2513,23 +2513,28 @@
 	_expand || return 0
 
 	if [[ "$cur" == *:* ]]; then
-		# remove backslash escape from :
-		cur=${cur/\\:/:}
-		userhost=${cur%%?(\\):*}
-		path=${cur#*:}
-		# unescape spaces
-		path=${path//\\\\\\\\ / }
-		if [ -z "$path" ]; then
-			# default to home dir of specified user on remote host
-			path=$(ssh -o 'Batchmode yes' $userhost pwd 2>/dev/null)
+		# if $COMP_SCP_REMOTE is not null, 'scp' will
+		# complete on remote host path (requires
+		# passwordless access to the remote host)
+		if [ -n "${COMP_SCP_REMOTE:-}" ]; then
+			# remove backslash escape from :
+			cur=${cur/\\:/:}
+			userhost=${cur%%?(\\):*}
+			path=${cur#*:}
+			# unescape spaces
+			path=${path//\\\\\\\\ / }
+			if [ -z "$path" ]; then
+				# default to home dir of specified user on remote host
+				path=$(ssh -o 'Batchmode yes' $userhost pwd 2>/dev/null)
+			fi
+			# 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' ) )
+			return 0
 		fi
-		# 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' ) )
-		return 0
 	fi
 
 	[[ "$cur" == */* ]] || _known_hosts -c -a