summaryrefslogtreecommitdiffstats
path: root/completions/badblocks
blob: 14e4e05ee831d5b9ae8c118e6b7301d222aaeae9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# badblocks(8) completion                                  -*- shell-script -*-

_comp_cmd_badblocks()
{
    local cur prev words cword comp_args
    _comp_initialize -- "$@" || return

    case $prev in
        -*[bcedpt])
            return
            ;;
        -*[io])
            _comp_compgen_filedir
            return
            ;;
    esac

    if [[ $cur == -* ]]; then
        # Filter out -w (dangerous) and -X (internal use)
        _comp_compgen -R usage
        ((${#COMPREPLY[@]})) &&
            _comp_compgen -- -X '-[wX]' -W '"${COMPREPLY[@]}"'
        return
    fi

    _comp_compgen -c "${cur:-/dev/}" filedir
} &&
    complete -F _comp_cmd_badblocks badblocks

# ex: filetype=sh