| 1 |
# lsmod(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 |
_lsmod() |
| 10 |
{ |
| 11 |
# long/short opt pairs |
| 12 |
local -A opts=( |
| 13 |
['syslog']='s' |
| 14 |
['verbose']='v' |
| 15 |
['version']='V' |
| 16 |
['help']='h' |
| 17 |
) |
| 18 |
|
| 19 |
local cur="${COMP_WORDS[COMP_CWORD]}" |
| 20 |
|
| 21 |
if [[ $cur == --* ]]; then |
| 22 |
COMPREPLY=($(compgen -P '--' -W "${!opts[*]}" -- "${cur:2}")) |
| 23 |
elif [[ $cur == -* ]]; then |
| 24 |
if (( ${#cur} != 2 )); then |
| 25 |
COMPREPLY=($(compgen -P '--' -W "${!opts[*]}" -- "${cur:2}")) |
| 26 |
fi |
| 27 |
COMPREPLY+=($(compgen -P '-' -W "${opts[*]}" -- "${cur:1}")) |
| 28 |
fi |
| 29 |
} && |
| 30 |
complete -F _lsmod lsmod |