@@ -8,24 +8,18 @@ _comp_cmd_mount()
8
8
local cur prev words cword comp_args
9
9
_comp_initialize -n =: -- " $@ " || return
10
10
11
- local split=" "
12
11
case " $prev " in
13
12
-t | --types)
14
13
# find /lib/modules/$(uname -r)/ -type f -path '*/fs/*.ko' -printf '%f\n' | cut -d. -f1
15
14
# FIXME: no<fstype>
16
- if [[ $cur == ?* ,* ]]; then
17
- prev=" ${cur% ,* } "
18
- cur=" ${cur##* ,} "
19
- split=set
20
- fi
21
- _comp_compgen -- -W ' auto adfs affs autofs btrfs cifs coda cramfs
22
- davfs debugfs devpts efs ext2 ext3 ext4 fuse hfs hfsplus hpfs
23
- iso9660 jffs2 jfs minix msdos ncpfs nfs nfs4 ntfs ntfs-3g proc
24
- qnx4 ramfs reiserfs romfs squashfs smbfs sysv tmpfs ubifs udf
25
- ufs umsdos usbfs vfat xfs'
26
- _comp_compgen -a fstypes
27
- [[ $split ]] && (( ${# COMPREPLY[@]} )) &&
28
- _comp_compgen -Rv COMPREPLY -- -P " $prev ," -W ' "${COMPREPLY[@]}"'
15
+ [[ $cur =~ ^.+, ]]
16
+ local prefix=${BASH_REMATCH-}
17
+ _comp_compgen -P " $prefix " -- -W ' auto adfs affs autofs btrfs cifs
18
+ coda cramfs davfs debugfs devpts efs ext2 ext3 ext4 fuse hfs
19
+ hfsplus hpfs iso9660 jffs2 jfs minix msdos ncpfs nfs nfs4 ntfs
20
+ ntfs-3g proc qnx4 ramfs reiserfs romfs squashfs smbfs sysv
21
+ tmpfs ubifs udf ufs umsdos usbfs vfat xfs'
22
+ _comp_compgen -aP " $prefix " fstypes
29
23
return
30
24
;;
31
25
--bind | -B | --rbind | -R)
@@ -66,145 +60,146 @@ _comp_cmd_mount()
66
60
# no<fstype> is not a real fstype, reset to "auto"
67
61
[[ $fstype == no?* ]] && fstype=auto
68
62
# split options list
69
- if [[ $cur == ?* ,* ]]; then
70
- prev=" ${cur% ,* } "
71
- cur=" ${cur##* ,} "
72
- split=set
73
- fi
63
+ [[ $cur =~ ^.+, ]]
64
+ local prefix=${BASH_REMATCH-}
74
65
# no completion if $cur is opt=smth
75
- [[ $cur == * = * ]] && return
66
+ [[ ${ cur##* ,} == * = * ]] && return
76
67
# mount options
77
- _comp_compgen -- -W ' loop {,a}sync {,no}atime {,no}auto
78
- {,fs,def,root}context= defaults {,no}dev {,no}diratime dirsync
79
- {,no}exec group {,no}iversion {,no}mand _netdev nofail
80
- {,no}relatime {,no}strictatime {,no}suid owner remount ro rw
81
- {,no}user users'
68
+ _comp_compgen -P " $prefix " -- -W ' loop {,a}sync {,no}atime
69
+ {,no}auto {, fs,def,root}context= defaults {,no}dev
70
+ {,no}diratime dirsync {,no} exec group {,no}iversion {,no}mand
71
+ _netdev nofail {,no}relatime {,no}strictatime {,no}suid owner
72
+ remount ro rw {,no}user users'
82
73
case " $fstype " in
83
74
adfs | auto)
84
- _comp_compgen -a -- -W ' {u,g}id= {own,oth}mask='
75
+ _comp_compgen -aP " $prefix " -- -W ' {u,g}id= {own,oth}mask='
85
76
;;&
86
77
affs | auto)
87
- _comp_compgen -a -- -W ' {u,g}id= set{u,g}id= mode= protect
88
- usemp verbose prefix= volume= reserved= root= bs =
89
- {,no,usr,grp}quota'
78
+ _comp_compgen -aP " $prefix " -- -W ' {u,g}id= set{u,g}id=
79
+ mode= protect usemp verbose prefix= volume= reserved=
80
+ root= bs= {,no,usr,grp}quota'
90
81
;;&
91
82
btrfs | auto)
92
- _comp_compgen -a -- -W ' degraded subvol= subvolid= device =
93
- nodatasum nodatacow nobarrier max_inline= alloc_start=
94
- thread_pool= compress= compress-force= ssd noacl
95
- notreelog flushoncommit metadata_ratio=
96
- {,no}space_cache clear_cache user_subvol_rm_allowed
97
- autodefrag inode_cache'
83
+ _comp_compgen -aP " $prefix " -- -W ' degraded subvol=
84
+ subvolid= device= nodatasum nodatacow nobarrier
85
+ max_inline= alloc_start= thread_pool= compress=
86
+ compress-force= ssd noacl notreelog flushoncommit
87
+ metadata_ratio= {,no}space_cache clear_cache
88
+ user_subvol_rm_allowed autodefrag inode_cache'
98
89
;;&
99
90
cifs | auto)
100
- _comp_compgen -a -- -W ' user= password= credentials =
101
- {u,g}id= force{u,g}id port= servern= netbiosname =
102
- {file,dir}_mode= ip= domain= guest iocharset
103
- {,no}setuids {,no,dyn}perm directio {,no}mapchars
104
- {,no}intr hard soft noacl nocase sec= nobrl sfu
105
- {,no}serverino nounix nouser_xattr {r,w}size=
91
+ _comp_compgen -aP " $prefix " -- -W ' user= password=
92
+ credentials= {u,g}id= force{u,g}id port= servern=
93
+ netbiosname= {file,dir}_mode= ip= domain= guest
94
+ iocharset {,no}setuids {,no,dyn}perm directio
95
+ {,no}mapchars {,no} intr hard soft noacl nocase sec=
96
+ nobrl sfu {,no}serverino nounix nouser_xattr {r,w}size=
106
97
rwpidforward backup{u,g}id cache='
107
98
;;&
108
99
davfs | auto)
109
- _comp_compgen -a -- -W ' conf= {file,dir}_mode= {u,g}id =
110
- username='
100
+ _comp_compgen -aP " $prefix " -- -W ' conf= {file,dir}_mode=
101
+ {u,g}id= username='
111
102
;;&
112
103
ext[2-4] | auto)
113
- _comp_compgen -a -- -W ' {,no}acl bsddf minixdf check= debug
114
- errors= {,no}grpid {bsd,sysv}groups {,no,usr,grp}quota
115
- nobh nouid32 oldalloc orlov res{u,g}id= sb=
116
- {,no}user_xattr'
104
+ _comp_compgen -aP " $prefix " -- -W ' {,no}acl bsddf minixdf
105
+ check= debug errors= {,no}grpid {bsd,sysv}groups
106
+ {,no,usr,grp}quota nobh nouid32 oldalloc orlov
107
+ res{u,g}id= sb= {,no}user_xattr'
117
108
;;&
118
109
ext[34] | auto)
119
- _comp_compgen -a -- -W ' journal= journal_dev= norecovery
120
- noload data= barrier= commit='
110
+ _comp_compgen -aP " $prefix " -- -W ' journal= journal_dev=
111
+ norecovery noload data= barrier= commit='
121
112
;;&
122
113
ext4 | auto)
123
- _comp_compgen -a -- -W ' journal_checksum
114
+ _comp_compgen -aP " $prefix " -- -W ' journal_checksum
124
115
journal_async_commit nobarrier inode_readahead= stripe=
125
116
{,no}delalloc abort {max,min}_batch_time=
126
117
journal_ioprio= {,no}auto_da_alloc {,no}discard nouid32
127
118
resize {,no}block_validity dioread_{,no}lock
128
119
max_dir_size_kb= i_version'
129
120
;;&
130
121
msdos | umsdos | vfat | auto)
131
- _comp_compgen -a -- -W ' blocksize= {u,g}id= {u,d,f}mask =
132
- allow_utime= check= codepage= conv= cvf_format =
133
- cvf_option= debug fat= iocharset= tz= quiet showexec
134
- sys_immutable flush usefree {,no}dots dotsOK='
122
+ _comp_compgen -aP " $prefix " -- -W ' blocksize= {u,g}id=
123
+ {u,d,f}mask= allow_utime= check= codepage= conv=
124
+ cvf_format= cvf_option= debug fat= iocharset= tz= quiet
125
+ showexec sys_immutable flush usefree {,no}dots dotsOK='
135
126
;;&
136
127
vfat | auto)
137
- _comp_compgen -a -- -W ' uni_xlate posix nonumtail utf8
138
- shortname='
128
+ _comp_compgen -aP " $prefix " -- -W ' uni_xlate posix
129
+ nonumtail utf8 shortname='
139
130
;;&
140
131
iso9660 | auto)
141
- _comp_compgen -a -- -W ' norock nojoliet check= {u,g}id =
142
- map= mode= unhide block= conv= cruft session= sbsector =
143
- iocharset= utf8'
132
+ _comp_compgen -aP " $prefix " -- -W ' norock nojoliet check=
133
+ {u,g}id= map= mode= unhide block= conv= cruft session=
134
+ sbsector= iocharset= utf8'
144
135
;;&
145
136
jffs2 | auto)
146
- _comp_compgen -a -- -W ' compr= rp_size='
137
+ _comp_compgen -aP " $prefix " -- -W ' compr= rp_size='
147
138
;;&
148
139
jfs | auto)
149
- _comp_compgen -a -- -W ' iocharset= resize= {,no}integrity
150
- errors= {,no,usr,grp}quota'
140
+ _comp_compgen -aP " $prefix " -- -W ' iocharset= resize=
141
+ {,no}integrity errors= {,no,usr,grp}quota'
151
142
;;&
152
143
nfs | nfs4 | auto)
153
- _comp_compgen -a -- -W ' soft hard timeo= retrans= {r,w}size=
154
- {,no}ac acreg{min,max}= acdir{min,max}= actimeo= bg fg
155
- retry= sec= {,no}sharecache {,no}resvport lookupcache=
156
- proto= port= {,no}intr {,no}cto {,nfs}vers='
144
+ _comp_compgen -aP " $prefix " -- -W ' soft hard timeo=
145
+ retrans= {r,w}size= {,no}ac acreg{min,max}=
146
+ acdir{min,max}= actimeo= bg fg retry= sec=
147
+ {,no}sharecache {,no}resvport lookupcache= proto= port=
148
+ {,no}intr {,no}cto {,nfs}vers='
157
149
;;&
158
150
nfs | auto)
159
- _comp_compgen -a -- -W ' udp tcp rdma mount{port,proto,host}=
160
- mountvers= namlen={,no}lock {,no}acl {,no}rdirplus
161
- {,no}fsc'
151
+ _comp_compgen -aP " $prefix " -- -W ' udp tcp rdma
152
+ mount{port,proto,host}= mountvers= namlen={,no}lock
153
+ {,no}acl {,no}rdirplus {,no} fsc'
162
154
;;&
163
155
nfs4 | auto)
164
- _comp_compgen -a -- -W ' clientaddr= {,no}migration'
156
+ _comp_compgen -aP " $prefix " -- -W ' clientaddr=
157
+ {,no}migration'
165
158
;;&
166
159
ntfs-3g)
167
- _comp_compgen -a -- -W ' {u,g}id= {u,f,d}mask= usermapping=
168
- permissions inherit locale= force {,no}recover
169
- ignore_case remove_hiberfile show_sys_files
170
- hide_{hid,dot}_files windows_names allow_other
171
- max_read= silent no_def_opts streams_interface=
172
- user_xattr efs_raw {,no}compression debug no_detach'
160
+ _comp_compgen -aP " $prefix " -- -W ' {u,g}id= {u,f,d}mask=
161
+ usermapping= permissions inherit locale= force
162
+ {,no}recover ignore_case remove_hiberfile
163
+ show_sys_files hide_{hid,dot}_files windows_names
164
+ allow_other max_read= silent no_def_opts
165
+ streams_interface= user_xattr efs_raw {,no}compression
166
+ debug no_detach'
173
167
;;&
174
168
proc | auto)
175
- _comp_compgen -a -- -W ' {u,g}id='
169
+ _comp_compgen -aP " $prefix " -- -W ' {u,g}id='
176
170
;;&
177
171
reiserfs | auto)
178
- _comp_compgen -a -- -W ' conv hash=
172
+ _comp_compgen -aP " $prefix " -- -W ' conv hash=
179
173
{,no_un}hashed_relocation noborder nolog notail
180
174
replayonly resize= user_xattr acl barrier='
181
175
;;&
182
176
tmpfs | auto)
183
- _comp_compgen -a -- -W ' size= nr_blocks= nr_inodes= mode =
184
- {u,g}id= mpol='
177
+ _comp_compgen -aP " $prefix " -- -W ' size= nr_blocks=
178
+ nr_inodes= mode= {u,g}id= mpol='
185
179
;;&
186
180
udf | auto)
187
- _comp_compgen -a -- -W ' {u,g}id= umask= unhide undelete
188
- nostrict iocharset bs= novrs session= anchor= volume =
189
- partition= lastblock= fileset= rootdir='
181
+ _comp_compgen -aP " $prefix " -- -W ' {u,g}id= umask= unhide
182
+ undelete nostrict iocharset bs= novrs session= anchor=
183
+ volume= partition= lastblock= fileset= rootdir='
190
184
;;&
191
185
usbfs | auto)
192
- _comp_compgen -a -- -W ' dev{u,g}id= devmode= bus{u,g}id =
193
- busmode= list{u,g}id= listmode='
186
+ _comp_compgen -aP " $prefix " -- -W ' dev{u,g}id= devmode=
187
+ bus{u,g}id= busmode= list{u,g}id= listmode='
194
188
;;&
195
189
xfs | auto)
196
- _comp_compgen -a -- -W ' allocsize= {,no}attr2 barrier dmapi
197
- {,no}grpid {bsd,sysv}groups ihashsize= {,no}ikeep
198
- inode{32,64} {,no}largeio logbufs= logbsize= logdev =
199
- rtdev= mtpt= noalign norecovery nouuid osyncisosync
200
- {u,g,p}qnoenforce {,u,usr,g,grp,p,prj}quota sunit=
201
- swidth= swalloc'
190
+ _comp_compgen -aP " $prefix " -- -W ' allocsize= {,no}attr2
191
+ barrier dmapi {,no}grpid {bsd,sysv}groups ihashsize=
192
+ {,no}ikeep inode{32,64} {,no}largeio logbufs= logbsize=
193
+ logdev= rtdev= mtpt= noalign norecovery nouuid
194
+ osyncisosync {u,g,p}qnoenforce
195
+ {,u,usr,g,grp,p,prj}quota sunit= swidth= swalloc'
202
196
;;&
203
197
esac
204
198
# COMP_WORDBREAKS is a real pain in the ass
205
- prev=" ${prev##* ["$COMP_WORDBREAKS"]} "
206
- [[ $split ]] && ((${COMPREPLY[@]} )) &&
207
- _comp_compgen -Rv COMPREPLY -- -P " $prev ," -W ' "${COMPREPLY[@]}"'
199
+ if ((${# COMPREPLY[@]} )) && [[ $prefix == * [" $COMP_WORDBREAKS " ]* ]]; then
200
+ local tmp=${prefix% ["$COMP_WORDBREAKS"]* }
201
+ COMPREPLY=(" ${COMPREPLY[@]# " $tmp " ?} " )
202
+ fi
208
203
[[ ${COMPREPLY-} == * = ]] && compopt -o nospace
209
204
return
210
205
;;
@@ -236,7 +231,7 @@ _comp_cmd_mount()
236
231
host=${cur#// }
237
232
host=${host%%/* }
238
233
if [[ $host ]]; then
239
- _comp_compgen -c " ${cur #// " $host " } " split -P " // $host " -- " $(
234
+ _comp_compgen -P " // $host " split -- " $(
240
235
smbclient -d 0 -NL " $host " 2> /dev/null |
241
236
command sed -ne ' /^[[:blank:]]*Sharename/,/^$/p' |
242
237
command sed -ne ' 3,$s|^[^A-Za-z]*\([^[:blank:]]*\).*$|/\1|p'
0 commit comments