Debian Codegraph @

shell-completion/bash/insmod

raw
1 # insmod(8) completion -*- shell-script -*-
2 # SPDX-License-Identifier: LGPL-2.1-or-later
3 #
4 # SPDX-FileCopyrightText: 2024 Emil Velikov <[email protected]>
5 #
6 # Formatted using:
7 # shfmt --language-dialect bash --indent 4 --func-next-line
8
9 _insmod()
10 {
11 # long/short opt pairs
12 local -A opts=(
13 ['force']='f'
14 ['syslog']='s'
15 ['verbose']='v'
16 ['version']='V'
17 ['help']='h'
18 )
19
20 local cur="${COMP_WORDS[COMP_CWORD]}"
21
22 if [[ $cur == --* ]]; then
23 COMPREPLY=($(compgen -P '--' -W "${!opts[*]}" -- "${cur:2}"))
24 elif [[ $cur == -* ]]; then
25 if (( ${#cur} != 2 )); then
26 COMPREPLY=($(compgen -P '--' -W "${!opts[*]}" -- "${cur:2}"))
27 fi
28 COMPREPLY+=($(compgen -P '-' -W "${opts[*]}" -- "${cur:1}"))
29 else
30 # TODO: match only one file
31 _filedir '@(ko?(.gz|.xz|.zst))'
32 # TODO: add module parameter completion, based of modinfo
33 fi
34 } &&
35 complete -F _insmod insmod