From 717b5e5bdd4dae67baa81a5507b3d4476842f874 Mon Sep 17 00:00:00 2001 From: ianmacd <> Date: Thu, 29 Nov 2001 00:37:54 +0000 Subject: [PATCH] removed _gid_function and made other modifications to account for the fact that group completion is now standard in bash 2.05a --- bash_completion | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/bash_completion b/bash_completion index 5fee08bf..9fd6a24e 100644 --- a/bash_completion +++ b/bash_completion @@ -1,8 +1,8 @@ -# bash_completion - some programmable completion functions for bash 2.05 +# bash_completion - some programmable completion functions for bash 2.05a # # # @@ -56,6 +56,9 @@ complete -A signal kill -P '%' # user commands see only users complete -u finger su usermod userdel passwd +# group commands see only groups +complete -u groupmod groupdel passwd + # bg completes with stopped jobs complete -A stopped -P '%' bg @@ -122,9 +125,7 @@ _chown() if [[ "$cur" == [a-zA-Z]*.* ]]; then user=${cur%.*} group=${cur#*.} - COMPREPLY=( $( awk 'BEGIN {FS=":"} \ - {if ($1 ~ /^'$group'/) print $1}' \ - /etc/group ) ) + COMPREPLY=( $( compgen -g $group ) ) for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do COMPREPLY[i]=$user.${COMPREPLY[i]} done @@ -155,21 +156,6 @@ _umount() } complete -F _umount -o filenames umount -# GID completion. This will get a list of all valid group names from -# /etc/group and should work anywhere. -# -_gid_func() -{ - local cur - - COMPREPLY=() - cur=${COMP_WORDS[COMP_CWORD]} - COMPREPLY=( $( awk 'BEGIN {FS=":"} {if ($1 ~ /^'$cur'/) print $1}' \ - /etc/group ) ) - return 0 -} -complete -F _gid_func groupdel groupmod - # mount(8) completion. This will pull a list of possible mounts out of # /etc/fstab, unless the word being completed contains a ':', which # would indicate the specification of an NFS server. In that case, we @@ -380,8 +366,7 @@ _find() return 0 ;; -group) - COMPREPLY=( $( awk 'BEGIN {FS=":"} \ - {if ($1 ~ /^'$cur'/) print $1}' /etc/group ) ) + COMPREPLY=( $( compgen -g $cur ) ) return 0 ;; -?(x)type) @@ -1294,7 +1279,6 @@ _command() if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=( $( compgen -c $cur ) ) else - # XXX sudo chkconfig should complete just as chkconfig would COMPREPLY=( $( compgen -f $cur ) ) fi } @@ -1358,7 +1342,7 @@ _p4() return 0 } -[ "$have" ] && complete -F _p4 -o default p4 +[ "$have" ] && complete -F _p4 -o default p4 g4 # # Return 1 if $1 appears to contain a redirection operator. Handles backslash