[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 25e4eb6df3748b73e837c912ac87f88814bc6efc

Freddy Vulto fvulto at gmail.com
Fri Jul 3 20:31:59 UTC 2009


The following commit has been merged in the master branch:
commit 25e4eb6df3748b73e837c912ac87f88814bc6efc
Author: Freddy Vulto <fvulto at gmail.com>
Date:   Fri Jul 3 22:28:13 2009 +0200

    Gave _known_hosts_real mandatory argument CWORD
    The option `-h hostname' to `_known_hosts_real' is removed.

diff --git a/bash_completion b/bash_completion
index c81688c..e38dca7 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1036,7 +1036,7 @@ _user_at_host() {
 	cur=`_get_cword`
 
 	if [[ $cur == *@* ]]; then
-		_known_hosts_real -h "$cur"
+		_known_hosts_real "$cur"
 	else
 		COMPREPLY=( $( compgen -u -- "$cur" ) )
 	fi
@@ -1049,24 +1049,21 @@ shopt -u hostcomplete && complete -F _user_at_host $nospace talk ytalk finger
 #       `_known_hosts_real' instead.
 _known_hosts()
 {
-	local cur
-
 	COMPREPLY=()
-	cur=`_get_cword`
 
 	# NOTE: Passing "$@" is deprecated.  See NOTE above.
-	_known_hosts_real -h "$cur" "$@"
+	_known_hosts_real "$@" "$(_get_cword)"
 }
 
 # Helper function for completing _known_hosts.
 # This function performs host completion based on ssh's known_hosts files,
 # defaulting to standard host completion if they don't exist.
-# Arguments:  -a             Use aliases
-#             -c             Use `:' suffix
-#             -F configfile  Use `configfile' for configuration settings
-#             -h hostname    Use hostname to complete on
-#             -p PREFIX      Use PREFIX
-# Return: Completions are added to COMPREPLY[]
+# Usage: _known_hosts_real [OPTIONS] CWORD
+# Options:  -a             Use aliases
+#           -c             Use `:' suffix
+#           -F configfile  Use `configfile' for configuration settings
+#           -p PREFIX      Use PREFIX
+# Return: Completions, starting with CWORD, are added to COMPREPLY[]
 _known_hosts_real()
 {
 	local configfile flag prefix
@@ -1075,15 +1072,16 @@ _known_hosts_real()
 	local IFS=$'\n'
 
 	local OPTIND=1
-	while getopts "acF:h:p:" flag "$@"; do
+	while getopts "acF:p:" flag "$@"; do
 		case $flag in
 			a) aliases='yes' ;;
 			c) suffix=':' ;;
 			F) configfile=$OPTARG ;;
-			h) cur=$OPTARG ;;
 			p) prefix=$OPTARG ;;
 		esac
 	done
+	[ $# -lt $OPTIND ] && echo "error: $FUNCNAME: missing mandatory argument CWORD"
+	cur=${!OPTIND}; let "OPTIND += 1"
 	[ $# -ge $OPTIND ] && echo "error: $FUNCNAME("$@"): unprocessed arguments:"\
 	    $(while [ $# -ge $OPTIND ]; do echo ${!OPTIND}; shift; done)
 
diff --git a/contrib/dhclient b/contrib/dhclient
index 49497f7..722dc69 100644
--- a/contrib/dhclient
+++ b/contrib/dhclient
@@ -17,7 +17,7 @@ have dhclient && _dhclient()
 			return 0
 			;;
 		-s)
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 	esac
diff --git a/contrib/dsniff b/contrib/dsniff
index 3561ec5..db3c972 100644
--- a/contrib/dsniff
+++ b/contrib/dsniff
@@ -20,7 +20,7 @@ _arpspoof()
 			return 0
 			;;
 		-t)
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 	esac
@@ -28,7 +28,7 @@ _arpspoof()
 	if [[ "$cur" == -* ]]; then
 		COMPREPLY=( $( compgen -W '-i -t' -- $cur ) )
 	else
-		_known_hosts_real -h "$cur"
+		_known_hosts_real "$cur"
 	fi
 
 } &&
@@ -157,7 +157,7 @@ _sshmitm()
 	if [[ "$cur" == -* ]]; then
 		COMPREPLY=( $( compgen -W '-d -I -p' -- $cur ) )
 	else
-		_known_hosts_real -h "$cur"
+		_known_hosts_real "$cur"
 	fi
 
 } &&
@@ -276,7 +276,7 @@ _webmitm()
 	if [[ "$cur" == -* ]]; then
 		COMPREPLY=( $( compgen -W '-d' -- $cur ) )
 	else
-		_known_hosts_real -h "$cur"
+		_known_hosts_real "$cur"
 	fi
 
 } &&
diff --git a/contrib/freeciv b/contrib/freeciv
index 4e69e36..6a68dca 100644
--- a/contrib/freeciv
+++ b/contrib/freeciv
@@ -50,7 +50,7 @@ _civclient()
 			return 0
 			;;
 		-@(s|-server))
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 	esac
diff --git a/contrib/gkrellm b/contrib/gkrellm
index 61d961d..38d4231 100644
--- a/contrib/gkrellm
+++ b/contrib/gkrellm
@@ -22,7 +22,7 @@ _gkrellm()
 			return 0
 			;;
 		-@(s|-server))
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 	esac
diff --git a/contrib/heimdal b/contrib/heimdal
index 14b26fc..594d719 100644
--- a/contrib/heimdal
+++ b/contrib/heimdal
@@ -47,7 +47,7 @@ _ktutil()
 			return 0
 			;;
 		-a|--admin-server)
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 		-r|--realm)
diff --git a/contrib/ldapvi b/contrib/ldapvi
index e2bde64..460db60 100644
--- a/contrib/ldapvi
+++ b/contrib/ldapvi
@@ -14,7 +14,7 @@ _ldapvi()
 
 	case "$prev" in
 		-@(h|-host))
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 		-@(Y|-sasl-mech))
diff --git a/contrib/munin-node b/contrib/munin-node
index 4b49b3a..6599df9 100644
--- a/contrib/munin-node
+++ b/contrib/munin-node
@@ -48,7 +48,7 @@ _munin-update()
 			return 0
 			;;
 		--host)
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 	esac
@@ -81,7 +81,7 @@ _munin-node-configure()
 			return 0
 			;;
 		--snmp)
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 		--snmpversion)
diff --git a/contrib/ntpdate b/contrib/ntpdate
index 90c4563..f717f58 100644
--- a/contrib/ntpdate
+++ b/contrib/ntpdate
@@ -27,7 +27,7 @@ _ntpdate()
 		COMPREPLY=( $( compgen -W '-4 -6 -b -B -d -Q -q -s -u -v -a\
 			-e -k -p -o -r -t' -- $cur ) )
 	else
-		_known_hosts_real -h "$cur"
+		_known_hosts_real "$cur"
 	fi
 } &&
 complete -F _ntpdate ntpdate
diff --git a/contrib/openldap b/contrib/openldap
index a53577b..5a63a24 100644
--- a/contrib/openldap
+++ b/contrib/openldap
@@ -24,7 +24,7 @@ _ldapsearch()
 
 	case "$prev" in
 		-h)
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 		-H)
@@ -73,7 +73,7 @@ _ldapaddmodify()
 
 	case "$prev" in
 		-h)
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 		-H)
@@ -111,7 +111,7 @@ _ldapdelete()
 
 	case "$prev" in
 		-h)
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 		-H)
@@ -146,7 +146,7 @@ _ldapcompare()
 
 	case "$prev" in
 		-h)
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 		-H)
@@ -181,7 +181,7 @@ _ldapmodrdn()
 
 	case "$prev" in
 		-h)
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 		-H)
@@ -216,7 +216,7 @@ _ldapwhoami()
 
 	case "$prev" in
 		-h)
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 		-H)
@@ -250,7 +250,7 @@ _ldappasswd()
 
 	case "$prev" in
 		-h)
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 		-H)
diff --git a/contrib/openssl b/contrib/openssl
index bd5b0a0..9835a6c 100644
--- a/contrib/openssl
+++ b/contrib/openssl
@@ -84,7 +84,7 @@ _openssl()
 				return 0
 				;;
 			-connect)
-				_known_hosts_real -h "$cur"
+				_known_hosts_real "$cur"
 				return 0
 				;;
 			-starttls)
diff --git a/contrib/postgresql b/contrib/postgresql
index 94b811b..98601c5 100644
--- a/contrib/postgresql
+++ b/contrib/postgresql
@@ -34,7 +34,7 @@ _createdb()
 
 	case "$prev" in
 		-h|--host)
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 		-U|--username|-O|--owner)
@@ -78,7 +78,7 @@ _dropdb()
 
 	case "$prev" in
 		-h|--host)
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 		-U|--username)
@@ -117,7 +117,7 @@ _psql()
 
 	case "$prev" in
 		-h|--host)
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 		-U|--username)
diff --git a/contrib/rdesktop b/contrib/rdesktop
index e35b2aa..1656ff1 100644
--- a/contrib/rdesktop
+++ b/contrib/rdesktop
@@ -46,7 +46,7 @@ _rdesktop()
 			-A -B -e -E -m -C -D -K -S -T -N -X -a -z -x -P -r \
 			-0 -4 -5' -- $cur ) )
 	else
-		_known_hosts_real -h "$cur"
+		_known_hosts_real "$cur"
 	fi
 
 } &&
diff --git a/contrib/rsync b/contrib/rsync
index 86a5c49..86ce634 100644
--- a/contrib/rsync
+++ b/contrib/rsync
@@ -87,7 +87,7 @@ _rsync()
 		fi
 		;;
 	*)
-		_known_hosts_real -c -a -h "$cur"
+		_known_hosts_real -c -a "$cur"
 		_filedir
 		;;
 	esac
diff --git a/contrib/ssh b/contrib/ssh
index 4244b62..09fe537 100644
--- a/contrib/ssh
+++ b/contrib/ssh
@@ -94,7 +94,7 @@ _ssh()
 			fi
 			shift
 		done
-		_known_hosts_real -a -h "$cur" $optconfigfile 
+		_known_hosts_real -a $optconfigfile "$cur"
 		if [ $COMP_CWORD -ne 1 ]; then
 			COMPREPLY=( "${COMPREPLY[@]}" $( compgen -c -- $cur ) )
 		fi
@@ -144,7 +144,7 @@ _sftp()
 			fi
 			shift
 		done
-		_known_hosts_real -a -h "$cur" $optconfigfile 
+		_known_hosts_real -a $optconfigfile "$cur"
 	fi
 
 	return 0
@@ -200,7 +200,7 @@ _scp()
 		shift
 	done
 
-	[[ "$cur" == */* ]] || _known_hosts_real -c -a -h "$cur" $optconfigfile 
+	[[ "$cur" == */* ]] || _known_hosts_real -c -a $optconfigfile "$cur"
 
 	# This approach is used instead of _filedir to get a space appended
 	# after local file/dir completions, and $nospace retained for others.
@@ -233,7 +233,7 @@ _ssh_copy_id() {
 	if [[ "$cur" == -* ]]; then
 		COMPREPLY=( $( compgen -W '-i' -- $cur ) )
 	else
-		_known_hosts_real -a -h "$cur"
+		_known_hosts_real -a "$cur"
 	fi
 
 	return 0
diff --git a/contrib/vncviewer b/contrib/vncviewer
index 8cfdd98..52db006 100644
--- a/contrib/vncviewer
+++ b/contrib/vncviewer
@@ -41,7 +41,7 @@ _tightvncviewer()
 			return 0
 			;;
 		-via)
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 	esac
@@ -54,7 +54,7 @@ _tightvncviewer()
 			-compresslevel -quality -nojpeg -nocursorshape \
 			-x11cursor' -- $cur ) )
 	else
-		_known_hosts_real -h "$cur"
+		_known_hosts_real "$cur"
 	fi
 } &&
 complete -F _tightvncviewer tightvncviewer
@@ -85,7 +85,7 @@ _xvnc4viewer()
 			;;
 		# -via
 		-[vV][iI][aA])
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 	esac
@@ -121,7 +121,7 @@ _xvnc4viewer()
 			)" -- "$(echo "$cur" | tr [:upper:] [:lower:])" ) )
 		fi
 	else
-		_known_hosts_real -h "$cur"
+		_known_hosts_real "$cur"
 	fi
 } &&
 complete -F _xvnc4viewer xvnc4viewer
diff --git a/contrib/vpnc b/contrib/vpnc
index 8197107..ef8fdf7 100644
--- a/contrib/vpnc
+++ b/contrib/vpnc
@@ -27,7 +27,7 @@ _vpnc()
 			return 0
 			;;
 		--gateway)
-			_known_hosts_real -h "$cur"
+			_known_hosts_real "$cur"
 			return 0
 			;;
 	esac
diff --git a/contrib/xhost b/contrib/xhost
index fd21255..02c7ba1 100644
--- a/contrib/xhost
+++ b/contrib/xhost
@@ -9,9 +9,9 @@ _xhost ()
 	local cur=`_get_cword`
 
 	case "$cur" in
-		+*) _known_hosts_real -h "${cur:1}" -p+ ;;
-		-*) _known_hosts_real -h "${cur:1}" -p- ;;
-		*)  _known_hosts_real -h "$cur" ;;
+		+*) _known_hosts_real -p+ "${cur:1}" ;;
+		-*) _known_hosts_real -p- "${cur:1}" ;;
+		*)  _known_hosts_real "$cur" ;;
 	esac
 
 	return 0
diff --git a/contrib/xm b/contrib/xm
index 859a0f3..b4b4bba 100644
--- a/contrib/xm
+++ b/contrib/xm
@@ -97,7 +97,7 @@ _xm()
 							_xen_domain_names
 							;;
 						3)
-							_known_hosts_real -h "$cur"
+							_known_hosts_real "$cur"
 							;;
 					esac
 					;;
diff --git a/test/unit/_known_hosts_real.exp b/test/unit/_known_hosts_real.exp
index 3378c82..9acd7b6 100644
--- a/test/unit/_known_hosts_real.exp
+++ b/test/unit/_known_hosts_real.exp
@@ -19,7 +19,7 @@ lappend hosts doo gee hus ike
 set hosts [lsort -ascii $hosts]
 set hosts [join $hosts "\\s+"]
     # Call _known_hosts
-set cmd {_known_hosts -aF fixtures/_known_hosts_real/config; echo_array COMPREPLY}
+set cmd {_known_hosts_real -aF fixtures/_known_hosts_real/config ''; echo_array COMPREPLY}
 send "$cmd\r"
 expect -ex "$cmd\r\n"
 expect {
@@ -41,7 +41,7 @@ lappend hosts gee hus doo ike two
 set hosts [lsort -ascii $hosts]
 set hosts [join $hosts "\\s+"]
     # Call _known_hosts
-set cmd {_known_hosts_real -aF 'fixtures/_known_hosts_real/spaced  conf'; echo_array COMPREPLY}
+set cmd {_known_hosts_real -aF 'fixtures/_known_hosts_real/spaced  conf' ''; echo_array COMPREPLY}
 send "$cmd\r"
 expect -ex "$cmd\r\n"
 expect {

-- 
bash-completion



More information about the Bash-completion-commits mailing list