diff options
Diffstat (limited to 'contrib/smartctl')
-rw-r--r-- | contrib/smartctl | 177 |
1 files changed, 87 insertions, 90 deletions
diff --git a/contrib/smartctl b/contrib/smartctl index 5108269f..74e42816 100644 --- a/contrib/smartctl +++ b/contrib/smartctl @@ -1,141 +1,138 @@ # bash completion for smartctl(8) -have smartctl && { +have smartctl && +{ _smartctl_quietmode() { - COMPREPLY=( $( compgen -W 'errorsonly silent noserial' -- "$cur" ) ) + COMPREPLY=( $( compgen -W 'errorsonly silent noserial' -- "$cur" ) ) } _smartctl_device() { - local i opts='ata scsi sat marvell hpt cciss' - for (( i=0; i <= 31; i++ )) ; do - opts="$opts 3ware,$i" - done - COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) ) + local i opts='ata scsi sat marvell hpt cciss' + for (( i=0; i <= 31; i++ )) ; do + opts="$opts 3ware,$i" + done + COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) ) } _smartctl_tolerance() { - COMPREPLY=( $( compgen -W 'normal conservative permissive \ - verypermissive' -- "$cur" ) ) + COMPREPLY=( $( compgen -W 'normal conservative permissive \ + verypermissive' -- "$cur" ) ) } _smartctl_badsum() { - COMPREPLY=( $( compgen -W 'warn exit ignore' -- "$cur" ) ) + COMPREPLY=( $( compgen -W 'warn exit ignore' -- "$cur" ) ) } _smartctl_report() { - COMPREPLY=( $( compgen -W 'ioctl ataioctl scsiioctl' -- "$cur" ) ) + COMPREPLY=( $( compgen -W 'ioctl ataioctl scsiioctl' -- "$cur" ) ) } _smartctl_powermode() { - COMPREPLY=( $( compgen -W 'never sleep standby idle' -- "$cur" ) ) + COMPREPLY=( $( compgen -W 'never sleep standby idle' -- "$cur" ) ) } _smartctl_feature() { - COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) + COMPREPLY=( $( compgen -W 'on off' -- "$cur" ) ) } _smartctl_log() { - COMPREPLY=( $( compgen -W 'error selftest selective directory' -- "$cur" ) ) + COMPREPLY=( $( compgen -W 'error selftest selective directory' -- "$cur" ) ) } _smartctl_vendorattribute() { - COMPREPLY=( $( compgen -W 'help 9,minutes 9,seconds 9,halfminutes \ - 9,temp 192,emergencyretractcyclect 193,loadunload \ - 194,10xCelsius 194,unknown 198,offlinescanuncsectorct \ - 200,writeerrorcount 201,detectedtacount 220,temp' -- "$cur" ) ) + COMPREPLY=( $( compgen -W 'help 9,minutes 9,seconds 9,halfminutes \ + 9,temp 192,emergencyretractcyclect 193,loadunload \ + 194,10xCelsius 194,unknown 198,offlinescanuncsectorct \ + 200,writeerrorcount 201,detectedtacount 220,temp' -- "$cur" ) ) } _smartctl_firmwarebug() { - COMPREPLY=( $( compgen -W 'none samsung samsung2 samsung3 swapid' \ + COMPREPLY=( $( compgen -W 'none samsung samsung2 samsung3 swapid' \ -- "$cur" ) ) } _smartctl_presets() { - COMPREPLY=( $( compgen -W 'use ignore show showall' -- "$cur" ) ) + COMPREPLY=( $( compgen -W 'use ignore show showall' -- "$cur" ) ) } _smartctl_test() { - COMPREPLY=( $( compgen -W 'offline short long conveyance select \ - afterselect,on afterselect,off pending scttempint' -- "$cur" ) ) + COMPREPLY=( $( compgen -W 'offline short long conveyance select \ + afterselect,on afterselect,off pending scttempint' -- "$cur" ) ) } _smartctl() { - local cur prev split=false + local cur prev split=false - COMPREPLY=() - cur=`_get_cword` - prev=${COMP_WORDS[COMP_CWORD-1]} + COMPREPLY=() + _get_comp_words_by_ref cur prev - _split_longopt && split=true + _split_longopt && split=true - case "$prev" in - -q|--quietmode) - _smartctl_quietmode - ;; - -d|--device) - _smartctl_device - return 0 - ;; - -t|--tolerance) - _smartctl_tolerance - return 0 - ;; - -b|--badsum) - _smartctl_badsum - return 0 - ;; - -r|--report) - _smartctl_report - return 0 - ;; - -n|--nocheck) - _smartctl_powermode - return 0 - ;; - -s|--smart|-o|--offlineauto|-S|--saveauto) - _smartctl_feature - return 0 - ;; - -l|--log) - _smartctl_log - return 0 - ;; - -v|--vendorattribute) - _smartctl_vendorattribute - return 0 - ;; - -F|--firmwarebug) - _smartctl_firmwarebug - return 0 - ;; - -P|--presets) - _smartctl_presets - return 0 - ;; - -t|--test) - _smartctl_test - return 0 - ;; - esac + case $prev in + -q|--quietmode) + _smartctl_quietmode + ;; + -d|--device) + _smartctl_device + return 0 + ;; + -t|--tolerance) + _smartctl_tolerance + return 0 + ;; + -b|--badsum) + _smartctl_badsum + return 0 + ;; + -r|--report) + _smartctl_report + return 0 + ;; + -n|--nocheck) + _smartctl_powermode + return 0 + ;; + -s|--smart|-o|--offlineauto|-S|--saveauto) + _smartctl_feature + return 0 + ;; + -l|--log) + _smartctl_log + return 0 + ;; + -v|--vendorattribute) + _smartctl_vendorattribute + return 0 + ;; + -F|--firmwarebug) + _smartctl_firmwarebug + return 0 + ;; + -P|--presets) + _smartctl_presets + return 0 + ;; + -t|--test) + _smartctl_test + return 0 + ;; + esac - $split && return 0 + $split && return 0 - if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-h --help --usage -V --version \ - --copyright --license-i --info -a --all -q \ - --quietmode -d --device -T --tolerance -b --badsum \ - -r --report -n --nocheck -s --smart -o --offlineauto \ - -S --saveauto -H --health -c --capabilities -A \ - --attributes -l --log -v --vendorattribute -F \ - --firmwarebug -P --presets -t --test -C \ - --captive -X --abort' -- "$cur" ) ) - else - cur=${cur:=/dev/} - _filedir - fi + if [[ "$cur" == -* ]]; then + COMPREPLY=( $( compgen -W '--help --version --info --all --quietmode \ + --device --tolerance --badsum --report --nocheck --smart \ + --offlineauto --saveauto --health --capabilities --attributes \ + --log --vendorattribute --firmwarebug --presets --test --captive \ + --abort' -- "$cur" ) ) + else + cur=${cur:=/dev/} + _filedir + fi } complete -F _smartctl smartctl } |