[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.3-529-g3f85172

Ville Skyttä ville.skytta at iki.fi
Wed Nov 9 16:17:19 UTC 2011


The following commit has been merged in the master branch:
commit 3f851722d7ec106b0cf4ec561dac45080c8e5d64
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Wed Nov 9 18:14:23 2011 +0200

    _services: Split xinetd service completion into _xinetd_services.
    
    Only Mandriva's service operates on xinetd services, chkconfig does it
    everywhere.

diff --git a/bash_completion b/bash_completion
index 497dbb5..76852c5 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1050,28 +1050,34 @@ _gids()
 #
 _backup_glob='@(#*#|*@(~|.@(bak|orig|rej|swp|dpkg*|rpm@(orig|new|save))))'
 
+# Complete on xinetd services
+#
+_xinetd_services()
+{
+    local xinetddir=/etc/xinetd.d
+    if [[ -d $xinetddir ]]; then
+        local restore_nullglob=$(shopt -p nullglob); shopt -s nullglob
+        local -a svcs=( $( printf '%s\n' $xinetddir/!($_backup_glob) ) )
+        $restore_nullglob
+        COMPREPLY+=( $( compgen -W '${svcs[@]#$xinetddir/}' -- "$cur" ) )
+    fi
+}
+
 # This function completes on services
 #
 _services()
 {
-    local sysvdirs famdir=/etc/xinetd.d
+    local sysvdirs
     _sysvdirs
 
     local restore_nullglob=$(shopt -p nullglob); shopt -s nullglob
-
     COMPREPLY=( $( printf '%s\n' ${sysvdirs[0]}/!($_backup_glob|functions) ) )
-
-    if [ -d $famdir ]; then
-        COMPREPLY+=( $( printf '%s\n' $famdir/!($_backup_glob) ) )
-    fi
-
     $restore_nullglob
 
     COMPREPLY+=( $( systemctl list-units --full --all 2>/dev/null | \
         awk '$1 ~ /\.service$/ { sub("\\.service$", "", $1); print $1 }' ) )
 
-    COMPREPLY=( $( compgen -W '${COMPREPLY[@]#@(${sysvdirs[0]}|$famdir)/}' \
-        -- "$cur" ) )
+    COMPREPLY=( $( compgen -W '${COMPREPLY[@]#${sysvdirs[0]}/}' -- "$cur" ) )
 }
 
 # This completes on a list of all available service scripts for the
@@ -1088,6 +1094,7 @@ _service()
 
     if [[ $cword -eq 1 && $prev == ?(*/)service ]]; then
         _services
+        [[ -e /etc/mandrake-release ]] && _xinetd_services
     else
         local sysvdirs
         _sysvdirs
diff --git a/completions/chkconfig b/completions/chkconfig
index d7935c6..b1dd925 100644
--- a/completions/chkconfig
+++ b/completions/chkconfig
@@ -8,6 +8,7 @@ _chkconfig()
     case $prev in
         --level=[1-6]|[1-6]|--list|--add|--del|--override)
             _services
+            _xinetd_services
             return 0
             ;;
         --level)
@@ -27,6 +28,7 @@ _chkconfig()
                 -- "$cur" ) )
         else
             _services
+            _xinetd_services
         fi
     fi
 } &&

-- 
bash-completion



More information about the Bash-completion-commits mailing list