# badblocks(8) completion -*- shell-script -*- proc _badblocks { local cur prev words cword _init_completion || return match $prev { with -b|-c|-e|-d|-p|-t return 0 with -i|-o _filedir return 0 } if [[ "$cur" == -* ]] { setglobal COMPREPLY = ''( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) ) # Filter out -w (dangerous) and -X (internal use) for i in [$(!COMPREPLY[@])] { [[ ${COMPREPLY[i]} == -[wX] ]] && unset 'COMPREPLY[i]' } return 0 } setglobal cur = $(cur:=/dev/) _filedir } && complete -F _badblocks badblocks # ex: ts=4 sw=4 et filetype=sh