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

Ville Skyttä ville.skytta at iki.fi
Wed Jun 9 20:15:41 UTC 2010


The following commit has been merged in the master branch:
commit 6068efc01fc9a31a9082b2e7f4f2a73baf45d9e6
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Wed Jun 9 22:19:05 2010 +0300

    Split service completion into contrib/service.

diff --git a/CHANGES b/CHANGES
index f98c235..783ddb6 100644
--- a/CHANGES
+++ b/CHANGES
@@ -56,6 +56,7 @@ bash-completion (2.x)
   * Protect grep invocations from user aliases (Alioth: 312143).
   * Split sshfs completion from contrib/ssh into contrib/sshfs.
   * Split mount and umount completion into contrib/mount.
+  * Split service completion into contrib/service.
   * Do basic HTML file completion with Firefox and Chrome and friends,
     and Epiphany.
   * Do basic diff/patch completion with cdiff and kompare.
diff --git a/Makefile.am b/Makefile.am
index ec8b7cc..8662bc8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -128,6 +128,7 @@ bashcomp_DATA = contrib/abook \
 		contrib/samba \
 		contrib/sbcl \
 		contrib/screen \
+		contrib/service \
 		contrib/shadow \
 		contrib/sitecopy \
 		contrib/smartctl \
diff --git a/bash_completion b/bash_completion
index c232989..e4caaa3 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1082,42 +1082,6 @@ _dvd_devices()
     patch configure build install reinstall deinstall clean clean-depends \
     kernel buildworld' make
 
-# This completes on a list of all available service scripts for the
-# 'service' command and/or the SysV init.d directory, followed by
-# that script's available commands
-#
-{ have service || [ -d /etc/init.d/ ]; } &&
-_service()
-{
-    local cur prev sysvdir
-
-    COMPREPLY=()
-    prev=${COMP_WORDS[COMP_CWORD-1]}
-    cur=`_get_cword`
-
-    # don't complete for things like killall, ssh and mysql if it's
-    # the standalone command, rather than the init script
-    [[ ${COMP_WORDS[0]} != @(*init.d/!(functions|~)|service) ]] && return 0
-
-    # don't complete past 2nd token
-    [ $COMP_CWORD -gt 2 ] && return 0
-
-    [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d
-
-    if [[ $COMP_CWORD -eq 1 ]] && [[ $prev == "service" ]]; then
-        _services
-    else
-        COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \
-            -ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \
-            $sysvdir/${prev##*/} 2>/dev/null`' -- "$cur" ) )
-    fi
-
-    return 0
-} &&
-complete -F _service service
-[ -d /etc/init.d/ ] && complete -F _service -o default \
-    $(for i in /etc/init.d/*; do printf '%s\n' ${i##*/}; done)
-
 
 # chown(1) completion
 #
diff --git a/contrib/service b/contrib/service
new file mode 100644
index 0000000..05732a9
--- /dev/null
+++ b/contrib/service
@@ -0,0 +1,45 @@
+# service(8) and /etc/init.d/* completion
+
+# This completes on a list of all available service scripts for the
+# 'service' command and/or the SysV init.d directory, followed by
+# that script's available commands
+#
+{ have service || [ -d /etc/init.d/ ]; } &&
+_service()
+{
+    local cur prev sysvdir
+
+    COMPREPLY=()
+    prev=${COMP_WORDS[COMP_CWORD-1]}
+    cur=`_get_cword`
+
+    # don't complete for things like killall, ssh and mysql if it's
+    # the standalone command, rather than the init script
+    [[ ${COMP_WORDS[0]} != @(*init.d/!(functions|~)|service) ]] && return 0
+
+    # don't complete past 2nd token
+    [ $COMP_CWORD -gt 2 ] && return 0
+
+    [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d
+
+    if [[ $COMP_CWORD -eq 1 ]] && [[ $prev == "service" ]]; then
+        _services
+    else
+        COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \
+            -ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \
+            $sysvdir/${prev##*/} 2>/dev/null`' -- "$cur" ) )
+    fi
+
+    return 0
+} &&
+complete -F _service service
+[ -d /etc/init.d/ ] && complete -F _service -o default \
+    $(for i in /etc/init.d/*; do printf '%s\n' ${i##*/}; done)
+
+# Local variables:
+# mode: shell-script
+# sh-basic-offset: 4
+# sh-indent-comment: t
+# indent-tabs-mode: nil
+# End:
+# ex: ts=4 sw=4 et filetype=sh

-- 
bash-completion



More information about the Bash-completion-commits mailing list