summaryrefslogtreecommitdiff
path: root/completions/modprobe
diff options
context:
space:
mode:
Diffstat (limited to 'completions/modprobe')
-rw-r--r--completions/modprobe46
1 files changed, 29 insertions, 17 deletions
diff --git a/completions/modprobe b/completions/modprobe
index 43a2b01b..16c8453a 100644
--- a/completions/modprobe
+++ b/completions/modprobe
@@ -6,18 +6,18 @@ _modprobe()
_init_completion -s || return
case "$prev" in
- -h|--help|-V|--version)
+ --help|--version|-!(-*)[hV])
return
;;
- -C|--config)
+ --config|-!(-*)C)
_filedir
return
;;
- -d|--dirname|-t|--type)
+ --dirname|--type|-!(-*)[dt])
_filedir -d
return
;;
- -S|--set-version)
+ --set-version|-!(-*)S)
_kernel_versions
return
;;
@@ -26,36 +26,36 @@ _modprobe()
$split && return
if [[ "$cur" == -* ]]; then
- COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+ COMPREPLY=( $(compgen -W '$(_parse_help "$1")' -- "$cur") )
if [[ ! $COMPREPLY ]]; then
- COMPREPLY=( $( compgen -W '-a --all -b --use-blacklist -C --config
+ COMPREPLY=( $(compgen -W '-a --all -b --use-blacklist -C --config
-c --showconfig --dump-modversions -d --dirname --first-time
--force-vermagic --force-modversion -f --force -i
--ignore-install --ignore-remove -l --list -n --dry-run -q
--quiet -R --resolve-alias -r --remove -S --set-version
--show-depends -s --syslog -t --type -V --version -v
- --verbose' -- "$cur" ) )
+ --verbose' -- "$cur") )
fi
[[ $COMPREPLY == *= ]] && compopt -o nospace
return
fi
- local i mode=insert module= version=$(uname -r)
+ local i mode=insert module="" version=$(uname -r)
for (( i=1; i < $cword; i++ )); do
case "${words[i]}" in
- -r|--remove)
+ --remove|-!(-*)r*)
mode=remove
;;
- -l|--list)
+ --list|-!(-*)l*)
mode=list
;;
--dump-modversions)
mode=file
;;
- -S|--set-version)
+ --set-version|-!(-*)S)
version=${words[i+1]} # -S is not $prev and not $cur
;;
- -C|--config|-d|--dirname|-t|--type)
+ --config|--dirname|--type|-!(-*)[Cdt])
((i++)) # skip option and its argument
;;
-*)
@@ -83,17 +83,29 @@ _modprobe()
_filedir '@(?(k)o?(.gz))'
elif [[ -n "$module" ]]; then
# do module parameter completion
- COMPREPLY=( $( compgen -W "$( PATH="$PATH:/sbin" modinfo \
- -p "$module" 2>/dev/null | \
- awk -F: '!/^[ \t]/ { print $1 }' )" -- "$cur" ) )
+ if [[ $cur == *=* ]]; then
+ prev=${cur%%=*}
+ cur=${cur#*=}
+ if PATH="$PATH:/sbin" modinfo -p "$module" 2>/dev/null \
+ | command grep -q "^$prev:.*(bool)"; then
+ local choices="on off"
+ [[ $cur ]] && choices="1 0 y Y n N on off"
+ COMPREPLY=( $(compgen -W "$choices" -- "$cur") )
+ fi
+ else
+ COMPREPLY=( $(compgen -S = -W "$(PATH="$PATH:/sbin" \
+ modinfo -p "$module" 2>/dev/null | \
+ awk -F: '!/^[ \t]/ { print $1 }')" -- "$cur") )
+ [[ $COMPREPLY == *= ]] && compopt -o nospace
+ fi
else
_modules $version
if [[ $COMPREPLY ]]; then
# filter out already installed modules
local -a mods=( "${COMPREPLY[@]}" )
_installed_modules "$cur"
- for i in ${!mods[@]}; do
- for module in ${COMPREPLY[@]}; do
+ for i in "${!mods[@]}"; do
+ for module in "${COMPREPLY[@]}"; do
if [[ ${mods[i]} == $module ]]; then
unset 'mods[i]'
break