[Bash-completion-commits] [bash-completion] 01/01: upstart support for service completion

Ville Skyttä scop-guest at moszumanska.debian.org
Wed Dec 17 12:43:17 UTC 2014


This is an automated email from the git hooks/post-receive script.

scop-guest pushed a commit to branch master
in repository bash-completion.

commit 3567d9354fbc40f050831559df17d442e3177a8d
Author: Peter Cordes <peter at cordes.ca>
Date:   Sat Dec 13 00:34:57 2014 -0400

    upstart support for service completion
    
    initctl list works for unprivileged users.
    
    Wasn't sure what file to check to detect that upstart was present, but
    /sbin should always be mounted, and upstart itself provides
    /sbin/upstart-udev-bridge, and it's not a conffile in /etc that someone
    could move if they wanted to on their local system.  upstart-dbus-bridge
    isn't present on Ubuntu 12.04, but socket and udev bridge both are.
    (Do Debian kFreeBSD or GNU/Hurd have udev?  nvm, Debian kFreeBSD doesn't
    ship upstart at all.)
    
    http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/lucid/upstart/lucid-updates/view/head:/debian/changelog
    indicates that the udev bridge existed as far back as Ubuntu 10.04
    (Lucid), and might have been the first bridge.  udev is probably here to stay, so use that, even udev is Linux only, unlike sockets.
    
     Another possiblity would be to check /usr/share/man/man7/upstart.7.gz,
    but that looks brittle.
    
     I think it's important to check that the system is using an upstart init,
    so you don't run initctl when completing in a root shell on another kind
    of system.  At worst, reboots, at best generates system log messages.
---
 bash_completion | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/bash_completion b/bash_completion
index ee47398..8c9fc81 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1137,6 +1137,10 @@ _services()
     COMPREPLY+=( $( systemctl list-units --full --all 2>/dev/null | \
         awk '$1 ~ /\.service$/ { sub("\\.service$", "", $1); print $1 }' ) )
 
+    if [[ -x /sbin/upstart-udev-bridge ]]; then
+        COMPREPLY+=( $( initctl list 2>/dev/null | cut -d' ' -f1 ) )
+    fi
+
     COMPREPLY=( $( compgen -W '${COMPREPLY[@]#${sysvdirs[0]}/}' -- "$cur" ) )
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/bash-completion/bash-completion.git



More information about the Bash-completion-commits mailing list