]> git.ipfire.org Git - thirdparty/util-linux.git/blob - bash-completion/mount
bash-completion: fix few bash set -u issues
[thirdparty/util-linux.git] / bash-completion / mount
1 _mount_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 '-t'|'--types')
9 local prefix realcur TYPES
10 TYPES="
11 $(\ls /lib/modules/$(uname -r)/kernel/fs | awk '{print $1, "no" $1}')
12 $(awk '{print $NF, "no" $NF}' /proc/filesystems)
13 "
14 realcur="${cur##*,}"
15 prefix="${cur%$realcur}"
16 for WORD in $TYPES; do
17 if ! [[ $prefix == *"$WORD"* ]]; then
18 TYPE_COLS="$WORD ${TYPE_COLS:-""}"
19 fi
20 done
21 compopt -o nospace
22 COMPREPLY=( $(compgen -P "$prefix" -W "$TYPE_COLS" -S ',' -- $realcur) )
23 return 0
24 ;;
25 '-L'|'--label')
26 local LABELS
27 LABELS="$(lsblk -o LABEL -nr)"
28 COMPREPLY=( $(compgen -W "$LABELS" -- $cur) )
29 return 0
30 ;;
31 '-U'|'--uuid')
32 local UUIDS
33 UUIDS="$(lsblk -o UUID -nr)"
34 COMPREPLY=( $(compgen -W "$UUIDS" -- $cur) )
35 return 0
36 ;;
37 '-h'|'--help'|'-V'|'--version')
38 return 0
39 ;;
40 esac
41 case $cur in
42 -*)
43 OPTS=" --all
44 --no-canonicalize
45 --fake
46 --fork
47 --fstab
48 --help
49 --internal-only
50 --show-labels
51 --no-mtab
52 --options
53 --test-opts
54 --read-only
55 --types
56 --source
57 --target
58 --verbose
59 --version
60 --read-write
61 --label
62 --uuid
63 --bind
64 --move
65 --rbind
66 --make-shared
67 --make-slave
68 --make-private
69 --make-unbindable
70 --make-rshared
71 --make-rslave
72 --make-rprivate
73 --make-runbindable"
74 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
75 return 0
76 ;;
77 esac
78 local IFS=$'\n'
79 compopt -o filenames
80 COMPREPLY=( $(compgen -f -- $cur) )
81 return 0
82 }
83 complete -F _mount_module mount