]> git.ipfire.org Git - thirdparty/util-linux.git/blame - bash-completion/lslocks
su: use lib/pty-session.c code for --pty
[thirdparty/util-linux.git] / bash-completion / lslocks
CommitLineData
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')
b5b80e5a
BE
17 local prefix realcur OUTPUT_ALL OUTPUT
18 realcur="${cur##*,}"
19 prefix="${cur%$realcur}"
20 OUTPUT_ALL="COMMAND PID TYPE SIZE MODE M START END PATH BLOCKER"
21 for WORD in $OUTPUT_ALL; do
22 if ! [[ $prefix == *"$WORD"* ]]; then
abbcec4f 23 OUTPUT="$WORD ${OUTPUT:-""}"
b5b80e5a
BE
24 fi
25 done
76dceb10 26 compopt -o nospace
b5b80e5a 27 COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- $realcur) )
76dceb10
SK
28 return 0
29 ;;
d4f9b8d7
VS
30 '-h'|'--help'|'-V'|'--version')
31 return 0
32 ;;
76dceb10 33 esac
c6b1d511
SK
34 OPTS="
35 --json
36 --noinaccessible
37 --noheadings
38 --output
25d3c405 39 --output-all
c6b1d511
SK
40 --pid
41 --raw
42 --notruncate
43 --help
44 --version
45 "
46 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
76dceb10 47 return 0
c6b1d511 48
76dceb10
SK
49}
50complete -F _lslocks_module lslocks