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

« back to all changes in this revision

Viewing changes to completions/ip

  • 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
# ip(8) completion                                         -*- shell-script -*-
 
2
 
 
3
_ip()
 
4
{
 
5
    local cur prev words cword
 
6
    _init_completion || return
 
7
 
 
8
    case $prev in
 
9
        -V|-Version|-rc|-rcvbuf)
 
10
            return 0
 
11
            ;;
 
12
        -f|-family)
 
13
            COMPREPLY=( $( compgen -W 'inet inet6 ipx dnet link' -- "$cur" ) )
 
14
            return 0
 
15
            ;;
 
16
        -b|-batch)
 
17
            _filedir
 
18
            return 0
 
19
            ;;
 
20
        -force)
 
21
            COMPREPLY=( $( compgen -W '-batch' -- "$cur" ) )
 
22
            return 0
 
23
            ;;
 
24
    esac
 
25
 
 
26
    local subcword cmd subcmd
 
27
    for (( subcword=1; subcword < ${#words[@]}-1; subcword++ )); do
 
28
        [[ ${words[subcword]} == -b?(atch) ]] && return 0
 
29
        [[ -n $cmd ]] && subcmd=${words[subcword]} && break
 
30
        [[ ${words[subcword]} != -* && \
 
31
                ${words[subcword-1]} != -@(f?(amily)|rc?(vbuf)) ]] && \
 
32
            cmd=${words[subcword]}
 
33
    done
 
34
 
 
35
    if [[ -z $cmd ]]; then
 
36
        case $cur in
 
37
            -*)
 
38
                local c="-Version -statistics -details -resolve -family
 
39
                    -oneline -timestamp -batch -rcvbuf"
 
40
                [[ $cword -eq 1 ]] && c+=" -force"
 
41
                COMPREPLY=( $( compgen -W "$c" -- "$cur" ) )
 
42
                return 0
 
43
                ;;
 
44
            *)
 
45
                COMPREPLY=( $( compgen -W "help $( ip help 2>&1 | \
 
46
                    sed -e '/OBJECT := /,/}/!d' \
 
47
                        -e 's/.*{//' -e 's/}.*//' -e 's/|//g' )" -- "$cur" ) )
 
48
                return 0
 
49
                ;;
 
50
        esac
 
51
    fi
 
52
 
 
53
    [[ $subcmd == help ]] && return 0
 
54
 
 
55
    case $cmd in
 
56
        link)
 
57
            case $subcmd in
 
58
                add)
 
59
                    # TODO
 
60
                    ;;
 
61
                delete)
 
62
                    case $(($cword-$subcword)) in
 
63
                        1)
 
64
                            _available_interfaces
 
65
                            ;;
 
66
                        2)
 
67
                            COMPREPLY=( $( compgen -W 'type' -- "$cur" ) )
 
68
                            ;;
 
69
                        3)
 
70
                            [[ $prev == type ]] && \
 
71
                                COMPREPLY=( $( compgen -W 'vlan veth vcan dummy
 
72
                                    ifb macvlan can' -- "$cur" ) )
 
73
                            ;;
 
74
                    esac
 
75
                    ;;
 
76
                set)
 
77
                    if [[ $cword-$subcword -eq 1 ]]; then
 
78
                        _available_interfaces
 
79
                    else
 
80
                        case $prev in
 
81
                            arp|dynamic|multicast|allmulticast|promisc|\
 
82
                            trailers)
 
83
                                COMPREPLY=( $( compgen -W 'on off' \
 
84
                                    -- "$cur" ) )
 
85
                                ;;
 
86
                            txqueuelen|name|address|broadcast|mtu|netns|alias)
 
87
                                ;;
 
88
                            *)
 
89
                                local c="arp dynamic multicast allmulticast
 
90
                                    promisc trailers txqueuelen name address
 
91
                                    broadcast mtu netns alias"
 
92
                                [[ $prev != @(up|down) ]] && c+=" up down"
 
93
                                COMPREPLY=( $( compgen -W "$c" -- "$cur" ) )
 
94
                                ;;
 
95
                        esac
 
96
                    fi
 
97
                    ;;
 
98
                show)
 
99
                    [[ $cword -eq $subcword+1 ]] && _available_interfaces
 
100
                    ;;
 
101
                *)
 
102
                    [[ $cword -eq $subcword ]] && \
 
103
                        COMPREPLY=( $( compgen -W 'help add delete set show' \
 
104
                        -- "$cur" ) )
 
105
                    ;;
 
106
            esac
 
107
            ;;
 
108
 
 
109
        addr)
 
110
            case $subcmd in
 
111
                add|change|replace)
 
112
                    # TODO
 
113
                    ;;
 
114
                del)
 
115
                    # TODO
 
116
                    ;;
 
117
                show|flush)
 
118
                    # TODO
 
119
                    ;;
 
120
                *)
 
121
                    [[ $cword -eq $subcword ]] && \
 
122
                        COMPREPLY=( $( compgen -W 'help add change replace del
 
123
                            show flush' -- "$cur" ) )
 
124
                    ;;
 
125
            esac
 
126
            ;;
 
127
 
 
128
        addrlabel)
 
129
            case $subcmd in
 
130
                list|add|del|flush)
 
131
                    # TODO
 
132
                    ;;
 
133
                *)
 
134
                    [[ $cword -eq $subcword ]] && \
 
135
                        COMPREPLY=( $( compgen -W 'help list add del flush' \
 
136
                        -- "$cur" ) )
 
137
                    ;;
 
138
            esac
 
139
            ;;
 
140
 
 
141
        route)
 
142
            case $subcmd in
 
143
                list|flush)
 
144
                    # TODO
 
145
                    ;;
 
146
                get)
 
147
                    # TODO
 
148
                    ;;
 
149
                add|del|change|append|replace|monitor)
 
150
                    # TODO
 
151
                    ;;
 
152
                *)
 
153
                    [[ $cword -eq $subcword ]] && \
 
154
                        COMPREPLY=( $( compgen -W 'help list flush get add del
 
155
                            change append replace monitor' -- "$cur" ) )
 
156
                    ;;
 
157
            esac
 
158
            ;;
 
159
 
 
160
        rule)
 
161
            case $subcmd in
 
162
                list|add|del|flush)
 
163
                    # TODO
 
164
                    ;;
 
165
                *)
 
166
                    [[ $cword -eq $subcword ]] && \
 
167
                        COMPREPLY=( $( compgen -W 'help list add del flush' \
 
168
                        -- "$cur" ) )
 
169
                    ;;
 
170
            esac
 
171
            ;;
 
172
 
 
173
        neigh)
 
174
            case $subcmd in
 
175
                add|del|change|replace)
 
176
                    # TODO
 
177
                    ;;
 
178
                show|flush)
 
179
                    # TODO
 
180
                    ;;
 
181
                *)
 
182
                    [[ $cword -eq $subcword ]] && \
 
183
                        COMPREPLY=( $( compgen -W 'help add del change replace
 
184
                            show flush' -- "$cur" ) )
 
185
                    ;;
 
186
            esac
 
187
            ;;
 
188
 
 
189
        ntable)
 
190
            case $subcmd in
 
191
                change)
 
192
                    # TODO
 
193
                    ;;
 
194
                show)
 
195
                    # TODO
 
196
                    ;;
 
197
                *)
 
198
                    [[ $cword -eq $subcword ]] && \
 
199
                        COMPREPLY=( $( compgen -W 'help change show' \
 
200
                        -- "$cur" ) )
 
201
                    ;;
 
202
            esac
 
203
            ;;
 
204
 
 
205
        tunnel)
 
206
            case $subcmd in
 
207
                add|change|del|show|prl|6rd)
 
208
                    # TODO
 
209
                    ;;
 
210
                *)
 
211
                    [[ $cword -eq $subcword ]] && \
 
212
                        COMPREPLY=( $( compgen -W 'help add change del show prl
 
213
                            6rd' -- "$cur" ) )
 
214
                    ;;
 
215
            esac
 
216
            ;;
 
217
 
 
218
        maddr)
 
219
            case $subcmd in
 
220
                add|del)
 
221
                    # TODO
 
222
                    ;;
 
223
                show)
 
224
                    if [[ $cword -eq $subcword+1 || $prev == dev ]]; then
 
225
                        _available_interfaces
 
226
                        [[ $prev != dev ]] && \
 
227
                            COMPREPLY=( $( compgen -W '${COMPREPLY[@]} dev' \
 
228
                            -- "$cur" ) )
 
229
                    fi
 
230
                    ;;
 
231
                *)
 
232
                    [[ $cword -eq $subcword ]] && \
 
233
                        COMPREPLY=( $( compgen -W 'help add del show' \
 
234
                        -- "$cur" ) )
 
235
                    ;;
 
236
            esac
 
237
            ;;
 
238
 
 
239
        mroute)
 
240
            case $subcmd in
 
241
                show)
 
242
                    # TODO
 
243
                    ;;
 
244
                *)
 
245
                    [[ $cword -eq $subcword ]] && \
 
246
                        COMPREPLY=( $( compgen -W 'help show' -- "$cur" ) )
 
247
                    ;;
 
248
            esac
 
249
            ;;
 
250
 
 
251
         monitor)
 
252
            case $subcmd in
 
253
                all) ;;
 
254
                *)
 
255
                    [[ $cword -eq $subcword ]] && \
 
256
                        COMPREPLY=( $( compgen -W 'help all' -- "$cur" ) )
 
257
                    ;;
 
258
            esac
 
259
            ;;
 
260
 
 
261
         xfrm)
 
262
            case $subcmd in
 
263
                state|policy|monitor)
 
264
                    # TODO
 
265
                    ;;
 
266
                *)
 
267
                    [[ $cword -eq $subcword ]] && \
 
268
                        COMPREPLY=( $( compgen -W 'state policy monitor' \
 
269
                        -- "$cur" ) )
 
270
                    ;;
 
271
            esac
 
272
            ;;
 
273
    esac
 
274
} &&
 
275
complete -F _ip ip
 
276
 
 
277
# ex: ts=4 sw=4 et filetype=sh