summaryrefslogtreecommitdiff
path: root/contrib/yp-tools
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/yp-tools')
-rw-r--r--contrib/yp-tools19
1 files changed, 10 insertions, 9 deletions
diff --git a/contrib/yp-tools b/contrib/yp-tools
index 60155279..7252a129 100644
--- a/contrib/yp-tools
+++ b/contrib/yp-tools
@@ -1,25 +1,26 @@
# bash completion for yp-tools
-have ypmatch &&
+have ypcat &&
_ypmatch()
{
- local cur map
+ local cur map cmd
COMPREPLY=()
- cur=`_get_cword`
+ _get_comp_words_by_ref cur
+ cmd=${1##*/}
- [ $1 = ypcat ] && [ $COMP_CWORD -gt 1 ] && return 0
- [ $1 = ypmatch ] && [ $COMP_CWORD -gt 2 ] && return 0
+ [[ $cmd == ypcat && $COMP_CWORD -gt 1 ]] && return 0
+ [[ $cmd == ypmatch && $COMP_CWORD -gt 2 ]] && return 0
- if [ $1 = ypmatch ] && [ $COMP_CWORD -eq 1 ] && \
- [ ${#COMP_WORDS[@]} -eq 3 ]; then
+ if [[ $cmd == ypmatch && $COMP_CWORD -eq 1 && \
+ ${#COMP_WORDS[@]} -eq 3 ]]; then
map=${COMP_WORDS[2]}
COMPREPLY=( $( compgen -W '$( ypcat $map | \
cut -d':' -f 1 )' -- "$cur") )
else
- [ $1 = ypmatch ] && [ $COMP_CWORD -ne 2 ] && return 0
+ [[ $cmd == ypmatch && $COMP_CWORD -ne 2 ]] && return 0
COMPREPLY=( $( compgen -W \
- '$( echo $(ypcat -x | cut -d"\"" -f 2))' -- "$cur"))
+ '$( printf "%s\n" $(ypcat -x | cut -d"\"" -f 2) )' -- "$cur"))
fi
return 0