[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 4fce53700073a9d65ebd20ac5756068fae32bc38
Guillaume Rousse
guillomovitch at zarb.org
Tue May 5 20:49:36 UTC 2009
The following commit has been merged in the master branch:
commit d5fd1c34120c6bae2cf459e386aa08c6bc7ad223
Author: Guillaume Rousse <guillomovitch at zarb.org>
Date: Sun May 3 15:18:31 2009 +0200
split _known_hosts into _kwnown_hosts and _known_hosts_real, instead of using an option to set current word
diff --git a/bash_completion b/bash_completion
index f5fcba9..146b412 100644
--- a/bash_completion
+++ b/bash_completion
@@ -2704,28 +2704,31 @@ shopt -u hostcomplete && complete -F _user_at_host $nospace talk ytalk finger
# -h host Complete on given host
_known_hosts()
{
+ local cur
+
+ COMPREPLY=()
+ cur=`_get_cword`
+
+ _known_hosts_real $@
+}
+
+_known_hosts_real()
+{
local configfile
- local cur curd ocur user suffix aliases global_kh user_kh hosts i host
+ local curd ocur user suffix aliases global_kh user_kh hosts i host
local -a kh khd config
local IFS=$'\n'
local OPTIND=1
- local cur_set=0
- while getopts "acF:h:" flag "$@"; do
+ while getopts "acF:" flag "$@"; do
case $flag in
a) aliases='yes' ;;
c) suffix=':' ;;
F) configfile="$OPTARG" ;;
- h) cur="$OPTARG"; cur_set=1 ;;
esac
done
- COMPREPLY=()
- if [ $cur_set = 0 ]; then
- cur=`_get_cword`
- fi
ocur=$cur
-
[[ $cur == *@* ]] && user=${cur%@*}@ && cur=${cur#*@}
kh=()
diff --git a/contrib/ssh b/contrib/ssh
index 032ad78..a445c8a 100644
--- a/contrib/ssh
+++ b/contrib/ssh
@@ -95,7 +95,7 @@ _ssh()
fi
shift
done
- _known_hosts -a "$optconfigfile"
+ _known_hosts_real -a "$optconfigfile"
else
COMPREPLY=( "${COMPREPLY[@]}" $( compgen -c -- $cur ) )
fi
@@ -145,7 +145,7 @@ _sftp()
fi
shift
done
- _known_hosts -a "$optconfigfile"
+ _known_hosts_real -a "$optconfigfile"
fi
return 0
@@ -201,7 +201,7 @@ _scp()
shift
done
- [[ "$cur" == */* ]] || _known_hosts -c -a "$optconfigfile"
+ [[ "$cur" == */* ]] || _known_hosts_real -c -a "$optconfigfile"
# This approach is used instead of _filedir to get a space appended
# after local file/dir completions, and $nospace retained for others.
@@ -234,7 +234,7 @@ _ssh_copy_id() {
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-i' -- $cur ) )
else
- _known_hosts -a
+ _known_hosts_real -a
fi
return 0
diff --git a/contrib/xhost b/contrib/xhost
index 7ed3c79..04c12c2 100644
--- a/contrib/xhost
+++ b/contrib/xhost
@@ -12,20 +12,20 @@ _xhost ()
case "$cur" in
+*)
cur=${cur:1}
- _known_hosts -h "$cur"
+ _known_hosts_real
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
COMPREPLY[i]=+${COMPREPLY[i]}
done
;;
-*)
cur=${cur:1}
- _known_hosts -h "$cur"
+ _known_hosts_real
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
COMPREPLY[i]=-${COMPREPLY[i]}
done
;;
*)
- _known_hosts -h "$cur"
+ _known_hosts_real
;;
esac
--
bash-completion
More information about the Bash-completion-commits
mailing list