Rong Tao c494150668 insmod: Support --force-{vermagic,modversion} arguments
Supports --force-{vermagic,modversion} parameter like modprobe.

Link: https://github.com/kmod-project/kmod/pull/340
Signed-off-by: Rong Tao <rongtao@cestc.cn>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2025-05-09 09:07:14 -05:00

38 lines
1.1 KiB
Bash

# insmod(8) completion -*- shell-script -*-
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# SPDX-FileCopyrightText: 2024 Emil Velikov <emil.l.velikov@gmail.com>
#
# Formatted using:
# shfmt --language-dialect bash --indent 4 --func-next-line
_insmod()
{
# long/short opt pairs
local -A opts=(
['force']='f'
['force-modversion']=''
['force-vermagic']=''
['syslog']='s'
['verbose']='v'
['version']='V'
['help']='h'
)
local cur="${COMP_WORDS[COMP_CWORD]}"
if [[ $cur == --* ]]; then
COMPREPLY=($(compgen -P '--' -W "${!opts[*]}" -- "${cur:2}"))
elif [[ $cur == -* ]]; then
if (( ${#cur} != 2 )); then
COMPREPLY=($(compgen -P '--' -W "${!opts[*]}" -- "${cur:2}"))
fi
COMPREPLY+=($(compgen -P '-' -W "${opts[*]}" -- "${cur:1}"))
else
# TODO: match only one file
_filedir '@(ko?(.gz|.xz|.zst))'
# TODO: add module parameter completion, based of modinfo
fi
} &&
complete -F _insmod insmod