[Bash-completion-devel] Bug#865548: bash-completion: completion for OpenRC rc-service

Mathieu Roy yeupou at gnu.org
Thu Jun 22 16:45:07 UTC 2017


Package: bash-completion
Version: 1:2.1-4.3
Severity: normal
Tags: patch

Hello,

With the following (almost a copy of invoke-rc.d), rc-service should
be handled ok.
(tried to sent it by mail to the mailing list but the list if for suscribers only)


# rc-service(8) completion                                -*-
  shell-script -*-
  #
  # cloned from update-rc.d
  # Copyright (C) 2004 Servilio Afre Puentes <servilio at gmail.com>

_rc_service()
{
    local cur prev words cword
        _init_completion || return

    local sysvdir services options valid_options

    sysvdir=/etc/init.d

    services=( $( printf '%s ' $sysvdir/!(README*|*.sh|$_backup_glob)
    ) )
        services=( ${services[@]#$sysvdir/} )
	    options=( --help --exists --ifexists --ifinactive
    --ifnotstarted  --list --nocolor --quiet )

    if [[ ($cword -eq 1) || ("$prev" == --* ) ]]; then
        valid_options=( $( \
	        tr " " "\n" <<<"${words[@]} ${options[@]}" \
		        | sed -ne "/$( sed "s/ /\\\\|/g"
        <<<"${options[@]}" )/p" \
	        | sort | uniq -u \
		        ) )
			    COMPREPLY=( $( compgen -W
        '${valid_options[@]} ${services[@]}' -- "$cur" ) )
	    elif [[ -x $sysvdir/$prev ]]; then
	            COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \
		                -ne "s/^.*Usage:[ ]*[^ ]*[
        ]*{*\([^}\"]*\).*$/\1/p" \
	            $sysvdir/$prev`' -- "$cur" ) )
		        else
			        COMPREPLY=()
				    fi

    return 0
    } &&
    complete -F _rc_service rc-service

# ex: ts=4 sw=4 et filetype=sh




Regards,


-- System Information:
Debian Release: 9.0
  APT prefers stable
  APT policy: (990, 'stable'), (500, 'oldstable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.9.0-3-amd64 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), LANGUAGE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages bash-completion depends on:
ii  bash  4.4-5
ii  dpkg  1.18.24

bash-completion recommends no packages.

bash-completion suggests no packages.

-- no debconf information



More information about the Bash-completion-devel mailing list