Use _split_longopt in mkinitrd.

This commit is contained in:
Ville Skyttä 2009-04-18 22:34:07 +03:00
parent 4dd5f087ae
commit 8a24a283a4
2 changed files with 17 additions and 27 deletions

View File

@ -35,7 +35,7 @@ bash-completion (1.x)
* Add _split_longopt() helper for improved handling of long options that * Add _split_longopt() helper for improved handling of long options that
take arguments in both "--foo bar" and "--foo=bar" formats. take arguments in both "--foo bar" and "--foo=bar" formats.
* Use _split_longopt to improve and clean up aspell, chgrp, chown, chkconfig, * Use _split_longopt to improve and clean up aspell, chgrp, chown, chkconfig,
iptables, make, smartctl, and generic long option completion. iptables, make, mkinitrd, smartctl, and generic long option completion.
* Add chown --from and --reference value completions. * Add chown --from and --reference value completions.
* Add chgrp --reference value completion. * Add chgrp --reference value completion.
* Do not assume all --foo= options take filenames in generic long option * Do not assume all --foo= options take filenames in generic long option

View File

@ -6,26 +6,16 @@
have mkinitrd && have mkinitrd &&
_mkinitrd() _mkinitrd()
{ {
local cur prev args local cur prev args split=false
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
# --name value style option _split_longopt && split=true
case "$prev" in
--preload)
_modules
return 0
;;
esac
# --name=value style option
if [[ "$cur" == *=* ]]; then
prev=${cur/=*/}
cur=${cur/*=/}
case "$prev" in case "$prev" in
--@(with|builtin)) --@(preload|with|builtin))
_modules _modules
return 0 return 0
;; ;;
@ -38,16 +28,16 @@ _mkinitrd()
return 0 return 0
;; ;;
esac esac
fi
$split && return 0
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--version --help -v -f --preload \ COMPREPLY=( $( compgen -W '--version --help -v -f --preload \
--force-scsi-probe --omit-scsi-modules \ --force-scsi-probe --omit-scsi-modules \
--omit-ide-modules --image-version --force-raid-probe \ --omit-ide-modules --image-version --force-raid-probe \
--omit-raid-modules --with= --force-lvm-probe \ --omit-raid-modules --with --force-lvm-probe \
--omit-lvm-modules --builtin= --omit-dmraid --net-dev= \ --omit-lvm-modules --builtin --omit-dmraid --net-dev \
--fstab= --nocompress --dsdt= --bootchart' -- $cur ) ) --fstab --nocompress --dsdt --bootchart' -- $cur ) )
else else
_count_args _count_args