skipcpio: return something at end of program
[dracut.git] / lsinitrd-bash-completion.sh
blob3df2965f47ccb1f0c09cefe7d31e758b04489231
2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
5 # Copyright 2013 Red Hat, Inc. All rights reserved.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 __contains_word () {
22 local word=$1; shift
23 for w in $*; do [[ $w = $word ]] && return 0; done
24 return 1
27 _lsinitrd() {
28 local field_vals= cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
29 local -A OPTS=(
30 [STANDALONE]='-s --size -h --help'
32 [ARG]='-f --file -k --kver'
35 if __contains_word "$prev" ${OPTS[ARG]}; then
36 case $prev in
37 --file|-f)
38 comps=$(compgen -f -- "$cur")
39 compopt -o filenames
41 --kver|-k)
42 comps=$(cd /lib/modules; echo [0-9]*)
45 return 0
47 esac
48 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
49 return 0
52 if [[ $cur = -* ]]; then
53 COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
54 return 0
57 comps=$(compgen -f -- "$cur")
58 compopt -o filenames
59 COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
60 return 0
63 complete -F _lsinitrd lsinitrd