diff options
Diffstat (limited to 'completions/mdadm')
-rw-r--r-- | completions/mdadm | 59 |
1 files changed, 24 insertions, 35 deletions
diff --git a/completions/mdadm b/completions/mdadm index 9cbaad7b..f0e917fd 100644 --- a/completions/mdadm +++ b/completions/mdadm @@ -1,13 +1,11 @@ -# bash completion for mdadm +# bash completion for mdadm -*- shell-script -*- -have mdadm && -{ _mdadm_raid_level() { local mode - for (( i=1; i < COMP_CWORD; i++ )); do - case ${COMP_WORDS[i]} in + for (( i=1; i < cword; i++ )); do + case ${words[i]} in -C|--create) mode=create break @@ -35,9 +33,9 @@ _mdadm_raid_level() _mdadm_raid_layout() { local level - for (( i=1; i < COMP_CWORD; i++ )); do - if [[ "${COMP_WORDS[i]}" == -@(l|-level) ]]; then - level=${COMP_WORDS[i+1]} + for (( i=1; i < cword; i++ )); do + if [[ "${words[i]}" == -@(l|-level) ]]; then + level=${words[i+1]} break fi done @@ -72,12 +70,8 @@ _mdadm_update_flag() _mdadm() { - local cur prev mode options split=false - - COMPREPLY=() - _get_comp_words_by_ref cur prev - - _split_longopt && split=true + local cur prev words cword split + _init_completion -s || return case $prev in -c|--config|-b|--bitmap|--backup-file) @@ -104,28 +98,29 @@ _mdadm() $split && return 0 + local options options='--help --help-options --version --verbose --quiet \ - --brief --force --config --scan --metadata --homehost' + --brief --force --config= --scan --metadata= --homehost=' if [[ "$cur" == -* ]]; then - if [[ $COMP_CWORD -eq 1 ]] ; then + if [[ $cword -eq 1 ]] ; then COMPREPLY=( $( compgen -W "$options --assemble --build \ --create --monitor --grow" -- "$cur" ) ) else - case ${COMP_WORDS[COMP_CWORD-1]} in + case ${words[cword-1]} in -A|--assemble) - COMPREPLY=( $( compgen -W "$options --uuid \ - --super-minor --name --force --run \ - --no-degraded --auto --bitmap --backup-file \ - --update --auto-update-homehost" -- "$cur" ) ) + COMPREPLY=( $( compgen -W "$options --uuid= \ + --super-minor= --name= --force --run \ + --no-degraded --auto= --bitmap= --backup-file= \ + --update= --auto-update-homehost" -- "$cur" ) ) ;; -B|-C|-G|--build|--create|--grow) - COMPREPLY=( $( compgen -W "$options --raid-devices \ - --spare-devices --size --chunk --rounding \ - --level --layout --parity --bitmap \ - --bitmap-chunk --write-mostly --write-behind \ - --assume-clean --backup-file --name --run \ - --force --auto" -- "$cur" ) ) + COMPREPLY=( $( compgen -W "$options --raid-devices= \ + --spare-devices= --size= --chunk= --rounding= \ + --level= --layout= --parity= --bitmap= \ + --bitmap-chunk= --write-mostly --write-behind= \ + --assume-clean --backup-file= --name= --run \ + --force --auto=" -- "$cur" ) ) ;; -F|--follow|--monitor) COMPREPLY=( $( compgen -W "$options --mail --program \ @@ -145,18 +140,12 @@ _mdadm() ;; esac fi + [[ $COMPREPLY == *= ]] && compopt -o nospace else cur=${cur:=/dev/} _filedir fi -} +} && complete -F _mdadm mdadm -} -# Local variables: -# mode: shell-script -# sh-basic-offset: 4 -# sh-indent-comment: t -# indent-tabs-mode: nil -# End: # ex: ts=4 sw=4 et filetype=sh |