mirror of
https://github.com/OpenRC/openrc.git
synced 2024-11-26 19:33:39 +08:00
remove the openrc-service-script bash completion
Bash completion has two official completion directories: - completionsdir, a lazy loading mechanism - compatdir, an eager loading mechanism Modern style is to use lazy loading if possible. It is modern technology, speeds up your shell by deferring loads, and is generally recommended for applications to prefer by default. It requires you name your completion script using the same name as the command to complete. Every distro prefers you do this, but only because bash-completion itself does. The openrc-service-script completion doesn't provide a completion for a command called openrc-service-script. It cannot use the lazy loading mechanism and emits a warning in Gentoo's policy lints as a result. Installing to the completionsdir is therefore a useless no-op. Better to install nothing. The compatdir is the correct location for completions that cannot be lazy loaded and must be loaded at shell startup in order to correctly register themselves for a globbed list of commands that can only be ascertained dynamically at shell startup. The alternative is to have every command that can be globbed install a symlink to openrc-service-script, and install openrc-service-script to a third location.
This commit is contained in:
parent
4dfec917cc
commit
917a7031d9
@ -8,7 +8,4 @@ bash_completions = [
|
||||
|
||||
install_data(bash_completions,
|
||||
install_dir : get_option('datadir') / 'bash-completion/completions')
|
||||
install_data(
|
||||
'openrc-service-script',
|
||||
install_dir : get_option('sysconfdir') / 'bash_completion.d')
|
||||
endif
|
||||
|
@ -1,29 +0,0 @@
|
||||
# Copyright (c) 2017 The OpenRC Authors.
|
||||
# See the Authors file at the top-level directory of this distribution and
|
||||
# https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS
|
||||
#
|
||||
# This file is part of OpenRC. It is subject to the license terms in
|
||||
# the LICENSE file found in the top-level directory of this
|
||||
# distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE
|
||||
# This file may not be copied, modified, propagated, or distributed
|
||||
# except according to the terms contained in the LICENSE file.
|
||||
|
||||
_openrc_service_script()
|
||||
{
|
||||
local script="${COMP_WORDS[0]}"
|
||||
local cur="${COMP_WORDS[$COMP_CWORD]}"
|
||||
|
||||
if [[ ( -f "${script}" || -h "${script}" ) && -r "${script}" ]] \
|
||||
&& [[ "$(head -n 1 "${script}")" =~ \#\!.*/openrc-run ]]
|
||||
then
|
||||
[[ $COMP_CWORD -gt 1 ]] && return 1
|
||||
COMPREPLY=($(opts="start stop status restart pause zap ineed needsme iuse usesme broken"; \
|
||||
eval "$(grep '^opts=' "${script}")"; echo "${opts}"))
|
||||
[[ -n "$COMPREPLY" ]] || COMPREPLY=(start stop restart zap)
|
||||
COMPREPLY=($(compgen -W "${COMPREPLY[*]}" -- "${cur}"))
|
||||
else
|
||||
COMPREPLY=($(compgen -o default -- "${cur}"))
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
complete -F _openrc_service_script */etc/init.d/*
|
Loading…
Reference in New Issue
Block a user