modprobe, modinfo, insmod: Move modprobe and modinfo completions to their own files.
Also fix some options handling and errors in unusual usecases (Alioth: #313498). Patch is partially written by Lekensteyn <lekensteyn@gmail.com> Reviewed-by: Sergey V <sftp.mtuci@gmail.com>master
parent
db53fc77a5
commit
f67818e023
|
@ -83,8 +83,6 @@ mailsnarf
|
|||
mdecrypt
|
||||
mencoder
|
||||
mkisofs
|
||||
modinfo
|
||||
modprobe
|
||||
mogrify
|
||||
montage
|
||||
mplayer2
|
||||
|
|
|
@ -193,6 +193,8 @@ bashcomp_DATA = a2x \
|
|||
mkinitrd \
|
||||
mktemp \
|
||||
mmsitepass \
|
||||
modinfo \
|
||||
modprobe \
|
||||
monodevelop \
|
||||
mount \
|
||||
mount.linux \
|
||||
|
@ -433,8 +435,6 @@ CLEANFILES = \
|
|||
mdecrypt \
|
||||
mencoder \
|
||||
mkisofs \
|
||||
modinfo \
|
||||
modprobe \
|
||||
mogrify \
|
||||
montage \
|
||||
mplayer2 \
|
||||
|
@ -639,10 +639,6 @@ symlinks:
|
|||
rm -f $(targetdir)/$$file && \
|
||||
$(LN_S) info $(targetdir)/$$file ; \
|
||||
done
|
||||
for file in modprobe modinfo ; do \
|
||||
rm -f $(targetdir)/$$file && \
|
||||
$(LN_S) insmod $(targetdir)/$$file ; \
|
||||
done
|
||||
for file in javac javadoc ; do \
|
||||
rm -f $(targetdir)/$$file && \
|
||||
$(LN_S) java $(targetdir)/$$file ; \
|
||||
|
|
|
@ -1,34 +1,18 @@
|
|||
# Linux insmod(8), modprobe(8) and modinfo(8) completion -*- shell-script -*-
|
||||
# This completes on the list of all available modules for the version of the
|
||||
# kernel currently running.
|
||||
#
|
||||
# Linux insmod(8) completion -*- shell-script -*-
|
||||
|
||||
_insmod()
|
||||
{
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
# behave like lsmod for modprobe -r
|
||||
if [[ ${1##*/} == modprobe && "${words[1]}" == -r ]]; then
|
||||
_installed_modules "$cur"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# do filename completion if we're giving a path to a module
|
||||
if [[ "$cur" == @(*/|[.~])* ]]; then
|
||||
# do filename completion for first argument
|
||||
if [[ $cword -eq 1 ]]; then
|
||||
_filedir '@(?(k)o?(.gz))'
|
||||
return 0
|
||||
else # do module parameter completion
|
||||
COMPREPLY=( $( compgen -W "$( /sbin/modinfo -p ${words[1]} \
|
||||
2>/dev/null | cut -d: -f1 )" -- "$cur" ) )
|
||||
fi
|
||||
|
||||
if [[ $cword -gt 1 && "${words[cword-1]}" != -* ]]; then
|
||||
# do module parameter completion
|
||||
COMPREPLY=( $( compgen -W "$( /sbin/modinfo -p ${words[1]} | \
|
||||
cut -d: -f1 )" -- "$cur" ) )
|
||||
else
|
||||
_modules $(uname -r)
|
||||
fi
|
||||
|
||||
return 0
|
||||
} &&
|
||||
complete -F _insmod insmod modprobe modinfo
|
||||
complete -F _insmod insmod
|
||||
|
||||
# ex: ts=4 sw=4 et filetype=sh
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
# Linux modinfo(8) completion -*- shell-script -*-
|
||||
|
||||
_modinfo()
|
||||
{
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case "$prev" in
|
||||
-F|--field)
|
||||
COMPREPLY=( $( compgen -W 'alias author depends description
|
||||
filename firmware license parm srcversion staging vermagic
|
||||
version' -- "$(echo "$cur" | tr '[:upper:]' '[:lower:]')" ) )
|
||||
return
|
||||
;;
|
||||
-k)
|
||||
_kernel_versions
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W '-V --version -F --field -k -0 --null -a -d
|
||||
-l -p -n' -- "$cur" ) )
|
||||
return
|
||||
fi
|
||||
|
||||
local i version=$(uname -r)
|
||||
for (( i=${#words[@]}-1; i>0; i-- )); do
|
||||
if [[ ${words[i]} == -k ]]; then
|
||||
version=${words[i+1]}
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# do filename completion if we're giving a path to a module
|
||||
if [[ "$cur" == @(*/|[.~])* ]]; then
|
||||
_filedir '@(?(k)o?(.gz))'
|
||||
else
|
||||
_modules $version
|
||||
fi
|
||||
} &&
|
||||
complete -F _modinfo modinfo
|
||||
|
||||
# ex: ts=4 sw=4 et filetype=sh
|
|
@ -0,0 +1,86 @@
|
|||
# Linux modprobe(8) completion -*- shell-script -*-
|
||||
|
||||
_modprobe()
|
||||
{
|
||||
local cur prev words cword
|
||||
_init_completion || return
|
||||
|
||||
case "$prev" in
|
||||
-C|--config)
|
||||
_filedir
|
||||
return
|
||||
;;
|
||||
-d|--dirname|-t|--type)
|
||||
_filedir -d
|
||||
return
|
||||
;;
|
||||
-S|--set-version)
|
||||
_kernel_versions
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "$cur" == -* ]]; then
|
||||
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" ) )
|
||||
return
|
||||
fi
|
||||
|
||||
local i mode=insert module= version=$(uname -r)
|
||||
for (( i=1; i < $cword; i++ )); do
|
||||
case "${words[i]}" in
|
||||
-r|--remove)
|
||||
mode=remove
|
||||
;;
|
||||
-l|--list)
|
||||
mode=list
|
||||
;;
|
||||
--dump-modversions)
|
||||
mode=file
|
||||
;;
|
||||
-S|--set-version)
|
||||
version=${words[i+1]} # -S is not $prev and not $cur
|
||||
;;
|
||||
-C|--config|-d|--dirname|-t|--type)
|
||||
((i++)) # skip option and its argument
|
||||
;;
|
||||
-*)
|
||||
# skip all other options
|
||||
;;
|
||||
*)
|
||||
[ -z "$module" ] && module=${words[i]}
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
case $mode in
|
||||
remove)
|
||||
_installed_modules "$cur"
|
||||
;;
|
||||
list)
|
||||
# no completion available
|
||||
;;
|
||||
file)
|
||||
_filedir
|
||||
;;
|
||||
insert)
|
||||
# do filename completion if we're giving a path to a module
|
||||
if [[ "$cur" == @(*/|[.~])* ]]; then
|
||||
_filedir '@(?(k)o?(.gz))'
|
||||
elif [[ -n "$module" ]]; then
|
||||
# do module parameter completion
|
||||
COMPREPLY=( $( compgen -W "$( /sbin/modinfo -p "$module" \
|
||||
2>/dev/null | cut -d: -f1 )" -- "$cur" ) )
|
||||
else
|
||||
_modules $version
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
} &&
|
||||
complete -F _modprobe modprobe
|
||||
|
||||
# ex: ts=4 sw=4 et filetype=sh
|
|
@ -0,0 +1 @@
|
|||
assert_source_completions modinfo
|
|
@ -0,0 +1 @@
|
|||
assert_source_completions modprobe
|
|
@ -11,7 +11,7 @@ proc teardown {} {
|
|||
setup
|
||||
|
||||
|
||||
assert_complete_any "insmod in"
|
||||
assert_complete_any "insmod "
|
||||
|
||||
|
||||
sync_after_int
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
proc setup {} {
|
||||
save_env
|
||||
}
|
||||
|
||||
|
||||
proc teardown {} {
|
||||
assert_env_unmodified
|
||||
}
|
||||
|
||||
|
||||
setup
|
||||
|
||||
|
||||
set test "in<TAB> should complete modulename"
|
||||
assert_complete_any "modinfo in" $test
|
||||
|
||||
|
||||
sync_after_int
|
||||
|
||||
|
||||
set test "should not complete anything for non-existent kernel"
|
||||
assert_no_complete "modinfo -k you-dont-have-such-kernel in" $test
|
||||
|
||||
|
||||
sync_after_int
|
||||
|
||||
|
||||
set test "should complete filepaths"
|
||||
assert_complete "/lib/" "modinfo /li" $test -nospace
|
||||
|
||||
|
||||
sync_after_int
|
||||
|
||||
|
||||
teardown
|
|
@ -0,0 +1,49 @@
|
|||
proc setup {} {
|
||||
save_env
|
||||
}
|
||||
|
||||
|
||||
proc teardown {} {
|
||||
assert_env_unmodified
|
||||
}
|
||||
|
||||
|
||||
setup
|
||||
|
||||
|
||||
set test "--remov<TAB> should complete \"--remove\""
|
||||
assert_complete "--remove" "modprobe --remov" $test
|
||||
|
||||
|
||||
sync_after_int
|
||||
|
||||
|
||||
set test "in<TAB> should complete modulename"
|
||||
assert_complete_any "modprobe in" $test
|
||||
|
||||
|
||||
sync_after_int
|
||||
|
||||
|
||||
set test "should not complete anything for non-existent kernel"
|
||||
assert_no_complete "modprobe -S you-dont-have-such-kernel in" $test
|
||||
|
||||
|
||||
sync_after_int
|
||||
|
||||
|
||||
set test "should not complete anything for non-existent module"
|
||||
assert_no_complete "modprobe you-dont-have-such-module " $test
|
||||
|
||||
|
||||
sync_after_int
|
||||
|
||||
|
||||
set test "should complete filepaths"
|
||||
assert_complete "/lib/" "modprobe /li" $test -nospace
|
||||
|
||||
|
||||
sync_after_int
|
||||
|
||||
|
||||
teardown
|
Loading…
Reference in New Issue