~ubuntu-branches/ubuntu/trusty/bash-completion/trusty-updates

« back to all changes in this revision

Viewing changes to completions/mount.linux

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2012-07-23 16:07:59 UTC
  • mfrom: (5.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20120723160759-lt9vn33dl3nak9l0
Tags: 1:2.0-1ubuntu1
* debian/maintscript, debian/postinst:
  - clean etc conffiles on upgrade since completion files are in /usr
    with the new version
* Resync with Debian, remaining diff
  * debian/patches/disable-avahi-browse.diff: Disable avahi-browse since
    it scales poorly in the current form: refresh patch
  * patches/101_bash_completion.oga_ogv.patch: Increase support for other
    OGG formats including .oga, .ogx, etc. (LP: #311525)
  * patches/103_colormake.patch: Add support for colormake to the make
    completion rules. (LP: #743208)
* Dropped changes:
  * Add conffile upgrade handling for a run of conffiles that were dropped
    since lucid: lucid upgrades are only supported to precise.
* Those fixes are in the new version
  * debian/patches/apt-get-changelog.patch:
  * Drop whitelists if they fail to produce any results:
  * patches/apt-get-download.patch: Add download as an apt-get
    sub-command (LP: #720541)
  * patches/102_manpager.patch: Override MANPAGER when generating perldoc
    completions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# mount(8) completion                                      -*- shell-script -*-
 
2
 
 
3
_mount()
 
4
{
 
5
    local cur prev words cword
 
6
    _init_completion -n =: || return
 
7
 
 
8
    local split=false
 
9
    case "$prev" in
 
10
        -t|--types)
 
11
            # find /lib/modules/$(uname -r)/ -type f -path '*/fs/*.ko' -printf '%f\n' | cut -d. -f1
 
12
            # FIXME: no<fstype>
 
13
            if [[ "$cur" == ?*,* ]]; then
 
14
                prev="${cur%,*}"
 
15
                cur="${cur##*,}"
 
16
                split=true
 
17
            fi
 
18
            COMPREPLY=( $(compgen -W 'auto adfs affs autofs btrfs cifs coda
 
19
                cramfs debugfs devpts efs ext2 ext3 ext4 fuse hfs hfsplus hpfs
 
20
                iso9660 jffs2 jfs minix msdos ncpfs nfs nfs4 ntfs ntfs-3g proc
 
21
                qnx4 ramfs reiserfs romfs squashfs smbfs sysv tmpfs ubifs udf
 
22
                ufs umsdos usbfs vfat xfs' -- "$cur") )
 
23
            _fstypes
 
24
            $split && COMPREPLY=( ${COMPREPLY[@]/#/$prev,} )
 
25
            return
 
26
            ;;
 
27
        --bind|-B|--rbind|-R)
 
28
            _filedir -d
 
29
            return
 
30
            ;;
 
31
        -p|--pass-fd)
 
32
            COMPREPLY=( $(compgen -W '{0..9}') )
 
33
            compopt -o nospace
 
34
            return
 
35
            ;;
 
36
        -L)
 
37
            COMPREPLY=( $( cd "/dev/disk/by-label/" 2>/dev/null || return; \
 
38
                compgen -f -- "$cur" ) )
 
39
            return
 
40
            ;;
 
41
        -U)
 
42
            COMPREPLY=( $( cd "/dev/disk/by-uuid/" 2>/dev/null || return; \
 
43
                compgen -f -- "$cur" ) )
 
44
            return
 
45
            ;;
 
46
        -O|--test-opts)
 
47
            # argument required but no completions available
 
48
            return
 
49
            ;;
 
50
        -o|--options)
 
51
            local fstype=auto # default fstype
 
52
            for (( i=${#words[@]}-1; i>0; i-- )); do
 
53
                if [[ "${words[i]}" == -@(t|-types)* ]]; then
 
54
                    if [[ "${words[i]}" == *=* ]]; then
 
55
                        [[ "${words[i]}" == ?*,* ]] && break
 
56
                        fstype="${words[i]#-*=}"
 
57
                    else
 
58
                        [[ "${words[i+1]}" == ?*,* ]] && break
 
59
                        fstype="${words[i+1]}"
 
60
                    fi
 
61
                    break
 
62
                fi
 
63
            done
 
64
            # no<fstype> is not a real fstype, reset to "auto"
 
65
            [[ "$fstype" == no?* ]] && fstype=auto
 
66
            # split options list
 
67
            if [[ "$cur" == ?*,* ]]; then
 
68
                prev="${cur%,*}"
 
69
                cur="${cur##*,}"
 
70
                split=true
 
71
            fi
 
72
            # no completion if $cur is opt=smth
 
73
            [[ "$cur" == *=* ]] && return
 
74
            # mount options
 
75
            COMPREPLY=( $(compgen -W 'loop async {,no}atime {,no}auto
 
76
                {,fs,def,root}context= defaults {,no}dev {,no}diratime dirsync
 
77
                {,no}exec group {,no}iversion {,no}mand _netdev nofail
 
78
                {,no}relatime {,no}strictatime {,no}suid owner remount ro rw
 
79
                sync {,no}user users' -- "$cur") )
 
80
            case "$fstype" in
 
81
            adfs|auto)
 
82
                COMPREPLY+=( $(compgen -W 'uid= gid= {own,oth}mask=' -- \
 
83
                    "$cur") )
 
84
                ;;&
 
85
            affs|auto)
 
86
                COMPREPLY+=( $(compgen -W '{u,g}id= set{u,g}id= mode= protect
 
87
                    usemp verbose prefix= volume= reserved= root= bs=
 
88
                    {,no,usr,grp}quota' -- "$cur") )
 
89
                ;;&
 
90
            btrfs|auto)
 
91
                COMPREPLY+=( $(compgen -W 'degraded subvol= subvolid= device=
 
92
                    nodatasum nodatacow nobarrier max_inline= alloc_start=
 
93
                    thread_pool= compress= compress-force= ssd noacl notreelog
 
94
                    flushoncommit metadata_ratio= {,no}space_cache clear_cache
 
95
                    user_subvol_rm_allowed autodefrag inode_cache' -- "$cur") )
 
96
                ;;&
 
97
            cifs|auto)
 
98
                COMPREPLY+=( $(compgen -W 'user= password= credentials= {u,g}id=
 
99
                    force{u,g}id port= servern= netbiosname= {file,dir}_mode=
 
100
                    ip= domain= guest iocharset ro rw {,no}setuids {,no,dyn}perm
 
101
                    directio {,no}mapchars {,no}intr hard soft noacl nocase sec=
 
102
                    nobrl sfu {,no}serverino nounix nouser_xattr {r,w}size=
 
103
                    rwpidforward backup{u,g}id' -- "$cur") )
 
104
                ;;&
 
105
            ext[2-4]|auto)
 
106
                COMPREPLY+=( $(compgen -W '{,no}acl bsddf minixdf check= debug
 
107
                    errors= {,no}grpid {bsd,sysv}groups {,no,usr,grp}quota
 
108
                    nobh nouid32 oldalloc orlov res{u,g}id= sb=
 
109
                    {,no}user_xattr' -- "$cur") )
 
110
                ;;&
 
111
            ext[34]|auto)
 
112
                COMPREPLY+=( $(compgen -W 'journal= journal_dev= norecovery
 
113
                    noload data= barrier= commit=' -- "$cur") )
 
114
                ;;&
 
115
            ext4|auto)
 
116
                COMPREPLY+=( $(compgen -W 'journal_checksum journal_async_commit
 
117
                    nobarrier inode_readahead= stripe= {,no}delalloc abort
 
118
                    {max,min}_batch_time= journal_ioprio= {,no}auto_da_alloc
 
119
                    {,no}discard nouid32 resize {,no}block_validity
 
120
                    dioread_{,no}lock i_version' -- "$cur") )
 
121
                ;;&
 
122
            msdos|umsdos|vfat|auto)
 
123
                COMPREPLY+=( $(compgen -W 'blocksize= {u,g}id= {u,d,f}mask=
 
124
                    allow_utime= check= codepage= conv= cvf_format= cvf_option=
 
125
                    debug fat= iocharset= tz= quiet showexec sys_immutable flush
 
126
                    usefree {,no}dots dotsOK=' -- "$cur") )
 
127
                ;;&
 
128
            vfat|auto)
 
129
                COMPREPLY+=( $(compgen -W 'uni_xlate posix nonumtail utf8
 
130
                    shortname=' -- "$cur") )
 
131
                ;;&
 
132
            iso9660|auto)
 
133
                COMPREPLY+=( $(compgen -W 'norock nojoliet check= {u,g}id= map=
 
134
                    mode= unhide block= conv= cruft session= sbsector=
 
135
                    iocharset= utf8' -- "$cur") )
 
136
                ;;&
 
137
            jffs2|auto)
 
138
                COMPREPLY+=( $(compgen -W 'compr=' -- "$cur") )
 
139
                ;;&
 
140
            jfs|auto)
 
141
                COMPREPLY+=( $(compgen -W 'iocharset= resize= {,no}integrity
 
142
                    errors= {,no,usr,grp}quota' -- "$cur") )
 
143
                ;;&
 
144
            ntfs-3g)
 
145
                COMPREPLY+=( $(compgen -W '{u,g}id= {u,f,d}mask= usermapping=
 
146
                    permissions inherit ro locale= force {,no}recover
 
147
                    ignore_case remove_hiberfile {,no,rel}atime show_sys_files
 
148
                    hide_{hid,dot}_files windows_names allow_other max_read=
 
149
                    silent no_def_opts streams_interface= user_xattr efs_raw
 
150
                    {,no}compression debug no_detach' -- "$cur") )
 
151
                ;;&
 
152
            proc|auto)
 
153
                COMPREPLY+=( $(compgen -W '{u,g}id=' -- "$cur") )
 
154
                ;;&
 
155
            reiserfs|auto)
 
156
                COMPREPLY+=( $(compgen -W 'conv hash= {,no_un}hashed_relocation
 
157
                    noborder nolog notail replayonly resize= user_xattr acl
 
158
                    barrier=' -- "$cur") )
 
159
                ;;&
 
160
            tmpfs|auto)
 
161
                COMPREPLY+=( $(compgen -W 'size= nr_blocks= nr_inodes= mode=
 
162
                    {u,g}id= mpol=' -- "$cur") )
 
163
                ;;&
 
164
            udf|auto)
 
165
                COMPREPLY+=( $(compgen -W '{u,g}id= umask= unhide undelete
 
166
                    nostrict iocharset bs= novrs session= anchor= volume=
 
167
                    partition= lastblock= fileset= rootdir=' -- "$cur") )
 
168
                ;;&
 
169
            usbfs|auto)
 
170
                COMPREPLY+=( $(compgen -W 'dev{u,g}id= devmode= bus{u,g}id=
 
171
                    busmode= list{u,g}id= listmode=' -- "$cur") )
 
172
                ;;&
 
173
            xfs|auto)
 
174
                COMPREPLY+=( $(compgen -W 'allocsize= {,no}attr2 barrier dmapi
 
175
                    {,no}grpid {bsd,sysv}groups ihashsize= {,no}ikeep inode64
 
176
                    {,no}largeio logbufs= logbsize= logdev= rtdev= mtpt= noalign
 
177
                    noatime norecovery nouuid osyncisosync {u,g,p}qnoenforce
 
178
                    {,u,usr,g,grp,p,prj}quota sunit= swidth= swalloc' \
 
179
                    -- "$cur") )
 
180
                ;;&
 
181
            esac
 
182
            # COMP_WORDBREAKS is a real pain in the ass
 
183
            prev="${prev##*[$COMP_WORDBREAKS]}"
 
184
            $split && COMPREPLY=( ${COMPREPLY[@]/#/"$prev,"} )
 
185
            [[ $COMPREPLY == *= ]] && compopt -o nospace
 
186
            return
 
187
            ;;
 
188
    esac
 
189
 
 
190
    if [[ "$cur" == -* ]]; then
 
191
        COMPREPLY=( $( compgen -W '--version --help --verbose --all --fork
 
192
            --fake --internal-only -l --no-mtab --no-canonicalize --pass-fd -s
 
193
            --read-only --rw -L -U --types --test-opts --options --bind --rbind
 
194
            --move' -- "$cur" ) )
 
195
        [[ $COMPREPLY ]] && return
 
196
    fi
 
197
 
 
198
    [[ "$cur" == \\ ]] && cur="/"
 
199
 
 
200
    local sm host
 
201
 
 
202
    if [[ "$cur" == *:* ]]; then
 
203
        for sm in "$(type -P showmount)" {,/usr}/{,s}bin/showmount; do
 
204
            [[ -x $sm ]] || continue
 
205
            COMPREPLY=( $( compgen -W "$( "$sm" -e ${cur%%:*} | \
 
206
                awk 'NR>1 {print $1}' )" -- "${cur#*:}" ) )
 
207
            return 0
 
208
        done
 
209
    fi
 
210
 
 
211
    if [[ "$cur" == //* ]]; then
 
212
        host=${cur#//}
 
213
        host=${host%%/*}
 
214
        if [[ -n $host ]]; then
 
215
            COMPREPLY=( $( compgen -P "//$host" -W \
 
216
                "$( smbclient -d 0 -NL $host 2>/dev/null |
 
217
                sed -ne '/^['"$'\t '"']*Sharename/,/^$/p' |
 
218
                sed -ne '3,$s|^[^A-Za-z]*\([^'"$'\t '"']*\).*$|/\1|p' )" \
 
219
                    -- "${cur#//$host}" ) )
 
220
        fi
 
221
    fi
 
222
 
 
223
    _filedir
 
224
} &&
 
225
complete -F _mount mount
 
226
 
 
227
# ex: ts=4 sw=4 et filetype=sh