| 1 |
_eject_module() |
| 2 |
{ |
| 3 |
local cur prev OPTS |
| 4 |
COMPREPLY=() |
| 5 |
cur="${COMP_WORDS[COMP_CWORD]}" |
| 6 |
prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 7 |
case $prev in |
| 8 |
'-a'|'--auto'|'-i'|'--manualeject') |
| 9 |
COMPREPLY=( $(compgen -W "off on" -- $cur) ) |
| 10 |
return 0 |
| 11 |
;; |
| 12 |
'-c'|'--changerslot') |
| 13 |
# FIXME: there must be way to determine slots |
| 14 |
COMPREPLY=( $(compgen -W "slot" -- $cur) ) |
| 15 |
return 0 |
| 16 |
;; |
| 17 |
'-x'|'--cdspeed') |
| 18 |
COMPREPLY=( $(compgen -W "$(command eject --listspeed 2>/dev/null)" -- $cur) ) |
| 19 |
return 0 |
| 20 |
;; |
| 21 |
'-h'|'--help'|'-V'|'--version') |
| 22 |
return 0 |
| 23 |
;; |
| 24 |
esac |
| 25 |
case $cur in |
| 26 |
-*) |
| 27 |
OPTS="--auto |
| 28 |
--changerslot |
| 29 |
--default |
| 30 |
--floppy |
| 31 |
--force |
| 32 |
--manualeject |
| 33 |
--no-unmount |
| 34 |
--no-partitions-unmount |
| 35 |
--noop |
| 36 |
--proc |
| 37 |
--tape |
| 38 |
--cdrom |
| 39 |
--scsi |
| 40 |
--trayclose |
| 41 |
--traytoggle |
| 42 |
--verbose |
| 43 |
--cdspeed |
| 44 |
--listspeed |
| 45 |
--help |
| 46 |
--version" |
| 47 |
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) |
| 48 |
return 0 |
| 49 |
;; |
| 50 |
esac |
| 51 |
local DEVS |
| 52 |
DEVS="$(for I in /sys/class/block/*/removable; do |
| 53 |
if [ $(command cat $I) -ne 0 ]; then |
| 54 |
OLD_IFS=$IFS |
| 55 |
IFS='/'; |
| 56 |
ARR=($I) |
| 57 |
echo "/dev/${ARR[4]}" |
| 58 |
IFS=$OLD_IFS |
| 59 |
fi |
| 60 |
done)" |
| 61 |
compopt -o bashdefault -o default |
| 62 |
COMPREPLY=( $(compgen -W "$DEVS" $cur) ) |
| 63 |
return 0 |
| 64 |
} |
| 65 |
complete -F _eject_module eject |