@@ -8,24 +8,18 @@ _comp_cmd_mount()
88 local cur prev words cword comp_args
99 _comp_initialize -n =: -- " $@ " || return
1010
11- local split=" "
1211 case " $prev " in
1312 -t | --types)
1413 # find /lib/modules/$(uname -r)/ -type f -path '*/fs/*.ko' -printf '%f\n' | cut -d. -f1
1514 # 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
2923 return
3024 ;;
3125 --bind | -B | --rbind | -R)
@@ -66,145 +60,146 @@ _comp_cmd_mount()
6660 # no<fstype> is not a real fstype, reset to "auto"
6761 [[ $fstype == no?* ]] && fstype=auto
6862 # 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-}
7465 # no completion if $cur is opt=smth
75- [[ $cur == * = * ]] && return
66+ [[ ${ cur##* ,} == * = * ]] && return
7667 # 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'
8273 case " $fstype " in
8374 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='
8576 ;;&
8677 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'
9081 ;;&
9182 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'
9889 ;;&
9990 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=
10697 rwpidforward backup{u,g}id cache='
10798 ;;&
10899 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='
111102 ;;&
112103 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'
117108 ;;&
118109 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='
121112 ;;&
122113 ext4 | auto)
123- _comp_compgen -a -- -W ' journal_checksum
114+ _comp_compgen -aP " $prefix " -- -W ' journal_checksum
124115 journal_async_commit nobarrier inode_readahead= stripe=
125116 {,no}delalloc abort {max,min}_batch_time=
126117 journal_ioprio= {,no}auto_da_alloc {,no}discard nouid32
127118 resize {,no}block_validity dioread_{,no}lock
128119 max_dir_size_kb= i_version'
129120 ;;&
130121 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='
135126 ;;&
136127 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='
139130 ;;&
140131 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'
144135 ;;&
145136 jffs2 | auto)
146- _comp_compgen -a -- -W ' compr= rp_size='
137+ _comp_compgen -aP " $prefix " -- -W ' compr= rp_size='
147138 ;;&
148139 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'
151142 ;;&
152143 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='
157149 ;;&
158150 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'
162154 ;;&
163155 nfs4 | auto)
164- _comp_compgen -a -- -W ' clientaddr= {,no}migration'
156+ _comp_compgen -aP " $prefix " -- -W ' clientaddr=
157+ {,no}migration'
165158 ;;&
166159 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'
173167 ;;&
174168 proc | auto)
175- _comp_compgen -a -- -W ' {u,g}id='
169+ _comp_compgen -aP " $prefix " -- -W ' {u,g}id='
176170 ;;&
177171 reiserfs | auto)
178- _comp_compgen -a -- -W ' conv hash=
172+ _comp_compgen -aP " $prefix " -- -W ' conv hash=
179173 {,no_un}hashed_relocation noborder nolog notail
180174 replayonly resize= user_xattr acl barrier='
181175 ;;&
182176 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='
185179 ;;&
186180 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='
190184 ;;&
191185 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='
194188 ;;&
195189 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'
202196 ;;&
203197 esac
204198 # 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
208203 [[ ${COMPREPLY-} == * = ]] && compopt -o nospace
209204 return
210205 ;;
@@ -236,7 +231,7 @@ _comp_cmd_mount()
236231 host=${cur#// }
237232 host=${host%%/* }
238233 if [[ $host ]]; then
239- _comp_compgen -c " ${cur #// " $host " } " split -P " // $host " -- " $(
234+ _comp_compgen -P " // $host " split -- " $(
240235 smbclient -d 0 -NL " $host " 2> /dev/null |
241236 command sed -ne ' /^[[:blank:]]*Sharename/,/^$/p' |
242237 command sed -ne ' 3,$s|^[^A-Za-z]*\([^[:blank:]]*\).*$|/\1|p'
0 commit comments