]> git.ipfire.org Git - thirdparty/util-linux.git/blob - bash-completion/blkid
rev: be careful with close()
[thirdparty/util-linux.git] / bash-completion / blkid
1 _blkid_module()
2 {
3 local cur prev OPTS OUTPUT_ALL
4 OUTPUT_ALL=''
5 COMPREPLY=()
6 cur="${COMP_WORDS[COMP_CWORD]}"
7 prev="${COMP_WORDS[COMP_CWORD-1]}"
8 case $prev in
9 '-c'|'--cache-file')
10 local IFS=$'\n'
11 compopt -o filenames
12 COMPREPLY=( $(compgen -f -- $cur) )
13 return 0
14 ;;
15 '-o'|'--output')
16 COMPREPLY=( $(compgen -W "value device export full" -- $cur) )
17 return 0
18 ;;
19 '-s'|'--match-tag')
20 COMPREPLY=( $(compgen -W "tag" -- $cur) )
21 return 0
22 ;;
23 '-t'|'--match-token')
24 COMPREPLY=( $(compgen -W "TYPE= LABEL= UUID=" -- $cur) )
25 return 0
26 ;;
27 '-L'|'--label')
28 COMPREPLY=( $(compgen -W "$(cd /dev/disk/by-label/ 2>/dev/null && echo *)" -- $cur) )
29 return 0
30 ;;
31 '-U'|'--uuid')
32 COMPREPLY=( $(compgen -W "$(cd /dev/disk/by-uuid/ 2>/dev/null && echo *)" -- $cur) )
33 return 0
34 ;;
35 '-S'|'--size')
36 COMPREPLY=( $(compgen -W "size" -- $cur) )
37 return 0
38 ;;
39 '-O'|'--offset')
40 COMPREPLY=( $(compgen -W "offset" -- $cur) )
41 return 0
42 ;;
43 '-u'|'--usages')
44 OUTPUT_ALL={,no}{filesystem,raid,crypto,other}
45 ;;
46 '-n'|'--match-types')
47 OUTPUT_ALL="
48 $(awk '{print $NF}' /proc/filesystems)
49 $(\ls /lib/modules/$(uname -r)/kernel/fs)
50 "
51 ;;
52 '-h'|'--help'|'-V'|'--version')
53 return 0
54 ;;
55 esac
56 if [ -n "$OUTPUT_ALL" ]; then
57 local prefix realcur OUTPUT_ALL OUTPUT
58 realcur="${cur##*,}"
59 prefix="${cur%$realcur}"
60 for WORD in $OUTPUT_ALL; do
61 if ! [[ $prefix == *"$WORD"* ]]; then
62 OUTPUT="$WORD ${OUTPUT:-""}"
63 fi
64 done
65 compopt -o nospace
66 COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- "$realcur") )
67 return 0
68 fi
69 case $cur in
70 -*)
71 OPTS="
72 --cache-file
73 --no-encoding
74 --garbage-collect
75 --output
76 --list-filesystems
77 --match-tag
78 --match-token
79 --list-one
80 --label
81 --uuid
82 --probe
83 --info
84 --size
85 --offset
86 --usages
87 --match-types
88 --no-part-details
89 --help
90 --version
91 "
92 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
93 return 0
94 ;;
95 esac
96 COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
97 return 0
98 }
99 complete -F _blkid_module blkid