shell-completion: use 4 space indentation too

The same as in other places, indentation levels were all over the place.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2019-04-12 08:34:44 +02:00
parent cc5549ca12
commit 843cfcb15c
39 changed files with 2518 additions and 2524 deletions
+29 -29
View File
@@ -17,45 +17,45 @@
# along with systemd; If not, see <http://www.gnu.org/licenses/>.
__contains_word () {
local w word=$1; shift
for w in "$@"; do
[[ $w = "$word" ]] && return
done
return 1
local w word=$1; shift
for w in "$@"; do
[[ $w = "$word" ]] && return
done
return 1
}
__get_names() {
systemd-path | { while IFS=: read -r a b; do echo " $a"; done; }
systemd-path | { while IFS=: read -r a b; do echo " $a"; done; }
}
_systemd_path() {
local comps
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local -A OPTS=(
[STANDALONE]='-h --help --version'
[ARG]='--suffix'
)
local comps
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local -A OPTS=(
[STANDALONE]='-h --help --version'
[ARG]='--suffix'
)
_init_completion || return
_init_completion || return
if __contains_word "$prev" ${OPTS[ARG]}; then
case $prev in
--suffix)
comps=''
;;
esac
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0
fi
if [[ "$cur" = -* ]]; then
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
return 0
fi
comps=$( __get_names )
if __contains_word "$prev" ${OPTS[ARG]}; then
case $prev in
--suffix)
comps=''
;;
esac
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0
fi
if [[ "$cur" = -* ]]; then
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
return 0
fi
comps=$( __get_names )
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0
}
complete -F _systemd_path systemd-path