sysv-rc: Bash completion script (included)

Karl Hegbloom hegbloom at pdx.edu
Sat May 21 19:11:35 UTC 2005


Package: sysv-rc
Version: 2.86-5ubuntu6
Severity: wishlist

Perhaps you might like to add this to the package?

    "/etc/bash_completion.d/invoke-rc.d"

8<------------------------------------------------------------>8
# -*- shell-script -*-
#
have invoke-rc.d &&
_invoke_rc_d()
{
    local scr cur conns savedIFS

    COMPREPLY=()
    cur=${COMP_WORDS[COMP_CWORD]}

    if [ $COMP_CWORD -eq 1 ]; then
	conns=$( ls /etc/init.d | egrep -v '(^\.|^#|~$|.bak$)' )
	COMPREPLY=( $( compgen -o filenames -W "$conns" $cur ) )
    fi

    if [ $COMP_CWORD -eq 2 ]; then
	scr=${COMP_WORDS[1]}
	conns=$(
	    eval $(grep 'echo .*Usage:' /etc/init.d/$scr) | cut -f 3 -d' ' | tr '|' ' '
	)
	if [ -z "$conns" ]; then
	    conns="start stop force-reload"
	fi
	COMPREPLY=( $( compgen -W "$conns" $cur ) )
    fi

    return 0
}
[ "$have" ] && complete -F _invoke_rc_d invoke-rc.d
8<------------------------------------------------------------>8


-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.11-lucgm.1
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

-- no debconf information




More information about the ubuntu-users mailing list