| 1 |
_flock_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 |
'-w'|'--timeout') |
| 9 |
COMPREPLY=( $(compgen -W "seconds" -- $cur) ) |
| 10 |
return 0 |
| 11 |
;; |
| 12 |
'-E'|'--conflict-exit-code') |
| 13 |
COMPREPLY=( $(compgen -W "{0..255}" -- $cur) ) |
| 14 |
return 0 |
| 15 |
;; |
| 16 |
'-c'|'--command') |
| 17 |
compopt -o bashdefault |
| 18 |
COMPREPLY=( $(compgen -c -- $cur) ) |
| 19 |
return 0 |
| 20 |
;; |
| 21 |
'-h'|'--help'|'-V'|'--version') |
| 22 |
return 0 |
| 23 |
;; |
| 24 |
esac |
| 25 |
case $cur in |
| 26 |
-*) |
| 27 |
OPTS="--shared |
| 28 |
--exclusive |
| 29 |
--unlock |
| 30 |
--nb |
| 31 |
--nonblocking |
| 32 |
--timeout |
| 33 |
--conflict-exit-code |
| 34 |
--close |
| 35 |
--command |
| 36 |
--no-fork |
| 37 |
--fcntl |
| 38 |
--start |
| 39 |
--length |
| 40 |
--wait |
| 41 |
--verbose |
| 42 |
--help |
| 43 |
--version" |
| 44 |
COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) |
| 45 |
return 0 |
| 46 |
;; |
| 47 |
esac |
| 48 |
local IFS=$'\n' |
| 49 |
compopt -o filenames |
| 50 |
COMPREPLY=( $(compgen -f -- ${cur:-"/"}) ) |
| 51 |
return 0 |
| 52 |
} |
| 53 |
complete -F _flock_module flock |