]> git.ipfire.org Git - thirdparty/util-linux.git/blob - bash-completion/mount
rev: be careful with close()
[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 '-N'|'--namespace')
38 local NAMESPACE
39 NAMESPACE="$(lsns --type mnt --output PATH --noheadings)"
40 COMPREPLY=( $(compgen -W "$NAMESPACE" -- $cur) )
41 return 0
42 ;;
43 '--options-mode')
44 COMPREPLY=( $(compgen -W "ignore append prepend replace" -- $cur) )
45 return 0
46 ;;
47 '--options-source')
48 COMPREPLY=( $(compgen -W "fstab mtab disable" -- $cur) )
49 return 0
50 ;;
51 '-h'|'--help'|'-V'|'--version')
52 return 0
53 ;;
54 esac
55 case $cur in
56 -*)
57 OPTS=" --all
58 --no-canonicalize
59 --fake
60 --fork
61 --fstab
62 --help
63 --internal-only
64 --show-labels
65 --no-mtab
66 --options
67 --options-mode
68 --options-source
69 --options-source-force
70 --test-opts
71 --read-only
72 --types
73 --source
74 --target
75 --verbose
76 --version
77 --read-write
78 --namespace
79 --label
80 --uuid
81 --bind
82 --move
83 --rbind
84 --make-shared
85 --make-slave
86 --make-private
87 --make-unbindable
88 --make-rshared
89 --make-rslave
90 --make-rprivate
91 --make-runbindable"
92 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
93 return 0
94 ;;
95 esac
96 local IFS=$'\n'
97 compopt -o filenames
98 COMPREPLY=( $(compgen -f -- $cur) )
99 return 0
100 }
101 complete -F _mount_module mount