]>
Commit | Line | Data |
---|---|---|
76dceb10 SK |
1 | _lslocks_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 | '-p'|'--pid') | |
9 | local PIDS | |
10 | # /proc/locks can have 8 to 9 fields, see commit | |
11 | # 55c0d16bab8cc84b72bf11cb2fdd8aa6205ac608 | |
12 | PIDS="$(awk '{print $(NF-3)}' /proc/locks)" | |
13 | COMPREPLY=( $(compgen -W "$PIDS" -- $cur) ) | |
14 | return 0 | |
15 | ;; | |
16 | '-o'|'--output') | |
17 | # FIXME: how to append to a string with compgen? | |
18 | local OUTPUT | |
19 | OUTPUT="COMMAND PID TYPE SIZE MODE M START END PATH BLOCKER" | |
20 | compopt -o nospace | |
21 | COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) ) | |
22 | return 0 | |
23 | ;; | |
d4f9b8d7 VS |
24 | '-h'|'--help'|'-V'|'--version') |
25 | return 0 | |
26 | ;; | |
76dceb10 SK |
27 | esac |
28 | case $cur in | |
29 | -*) | |
30 | OPTS="-p --pid | |
31 | -o --output | |
32 | -n --noheadings | |
33 | -r --raw | |
34 | -u --notruncate | |
35 | -h --help | |
36 | -V --version" | |
37 | COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) | |
38 | return 0 | |
39 | ;; | |
40 | esac | |
41 | compopt -o filenames | |
42 | COMPREPLY=( $(compgen -f -- $cur) ) | |
43 | return 0 | |
44 | } | |
45 | complete -F _lslocks_module lslocks |