@@ -88,10 +88,20 @@ _tipc()
88
88
;;
89
89
esac
90
90
91
+ if [[ $cword -eq 1 ]]; then
92
+ COMPREPLY=( $( compgen -W ' bearer link media nametable node socket' -- $cur ) )
93
+ return
94
+ fi
95
+
91
96
case " ${words[$optind]} " in
92
97
bearer)
93
98
let optind++
94
99
100
+ if [[ $cword -eq $optind ]]; then
101
+ COMPREPLY=( $( compgen -W ' enable disable set get list' -- $cur ) )
102
+ return
103
+ fi
104
+
95
105
case " ${words[$optind]} " in
96
106
enable)
97
107
local media params
@@ -139,13 +149,11 @@ _tipc()
139
149
done
140
150
141
151
COMPREPLY=( $( compgen -W ' ${params[@]}' -- $cur ) )
142
- return
143
152
;;
144
153
disable)
145
154
let optind++
146
155
147
156
_tipc_bearer $optind
148
- return
149
157
;;
150
158
get)
151
159
let optind++
@@ -155,7 +163,6 @@ _tipc()
155
163
elif [[ $cword -ge $optind +1 ]]; then
156
164
_tipc_bearer $(( $optind + 1 ))
157
165
fi
158
- return
159
166
;;
160
167
set)
161
168
let optind++
@@ -165,19 +172,17 @@ _tipc()
165
172
elif [[ $cword -ge $optind +2 ]]; then
166
173
_tipc_bearer $(( $optind + 2 ))
167
174
fi
168
- return
169
- ;;
170
- list)
171
- return
172
175
;;
173
176
esac
174
-
175
- COMPREPLY=( $( compgen -W ' enable disable set get list' -- $cur ) )
176
- return
177
177
;;
178
178
link)
179
179
let optind++
180
180
181
+ if [[ $cword -eq $optind ]]; then
182
+ COMPREPLY=( $( compgen -W ' get set list statistics' -- $cur ) )
183
+ return
184
+ fi
185
+
181
186
case " ${words[$optind]} " in
182
187
get)
183
188
let optind++
@@ -187,7 +192,6 @@ _tipc()
187
192
elif [[ $cword -ge $optind +1 ]]; then
188
193
_tipc_link $(( $optind + 1 )) " peers"
189
194
fi
190
- return
191
195
;;
192
196
set)
193
197
let optind++
@@ -197,32 +201,31 @@ _tipc()
197
201
elif [[ $cword -ge $optind +2 ]]; then
198
202
_tipc_link $(( $optind + 2 )) " peers"
199
203
fi
200
- return
201
- ;;
202
- list)
203
- return
204
204
;;
205
205
statistics)
206
206
let optind++
207
207
208
+ if [[ $cword -eq $optind ]]; then
209
+ COMPREPLY=( $( compgen -W ' show reset' -- $cur ) )
210
+ return
211
+ fi
212
+
208
213
case " ${words[$optind]} " in
209
214
show|reset)
210
215
_tipc_link $(( $optind + 1 ))
211
- return
212
216
;;
213
217
esac
214
-
215
- COMPREPLY=( $( compgen -W ' show reset' -- $cur ) )
216
- return
217
218
;;
218
219
esac
219
-
220
- COMPREPLY=( $( compgen -W ' get set list statistics' -- $cur ) )
221
- return
222
220
;;
223
221
media)
224
222
let optind++
225
223
224
+ if [[ $cword -eq $optind ]]; then
225
+ COMPREPLY=( $( compgen -W ' get set list' -- $cur ) )
226
+ return
227
+ fi
228
+
226
229
case " ${words[$optind]} " in
227
230
get)
228
231
let optind++
@@ -232,7 +235,6 @@ _tipc()
232
235
elif [[ $cword -ge $optind +1 ]]; then
233
236
_tipc_media $(( $optind + 1 ))
234
237
fi
235
- return
236
238
;;
237
239
set)
238
240
let optind++
@@ -242,66 +244,41 @@ _tipc()
242
244
elif [[ $cword -ge $optind +2 ]]; then
243
245
_tipc_media $(( $optind + 2 ))
244
246
fi
245
- return
246
- ;;
247
- list)
248
- return
249
247
;;
250
248
esac
251
-
252
- COMPREPLY=( $( compgen -W ' get set list' -- $cur ) )
253
- return
254
249
;;
255
250
nametable)
256
251
let optind++
257
252
258
- case " ${words[$optind]} " in
259
- show)
260
- return
261
- ;;
262
- esac
263
-
264
- COMPREPLY=( $( compgen -W ' show' -- $cur ) )
265
- return
253
+ if [[ $cword -eq $optind ]]; then
254
+ COMPREPLY=( $( compgen -W ' show' -- $cur ) )
255
+ fi
266
256
;;
267
257
node)
268
258
let optind++
269
259
260
+ if [[ $cword -eq $optind ]]; then
261
+ COMPREPLY=( $( compgen -W ' list get set' -- $cur ) )
262
+ return
263
+ fi
264
+
270
265
case " ${words[$optind]} " in
271
266
get|set)
272
267
let optind++
273
268
274
- case " ${words[$optind]} " in
275
- address|netid)
276
- return
277
- ;;
278
- esac
279
- COMPREPLY=( $( compgen -W ' address netid' -- $cur ) )
280
- return
281
- ;;
282
- list)
283
- return
284
- ;;
269
+ if [[ $cword -eq $optind ]]; then
270
+ COMPREPLY=( $( compgen -W ' address netid' -- $cur ) )
271
+ fi
285
272
esac
286
-
287
- COMPREPLY=( $( compgen -W ' list get set' -- $cur ) )
288
- return
289
273
;;
290
274
socket)
291
275
let optind++
292
276
293
- case " ${words[$optind]} " in
294
- list)
295
- return
296
- ;;
297
- esac
298
-
299
- COMPREPLY=( $( compgen -W ' list' -- $cur ) )
300
- return
277
+ if [[ $cword -eq $optind ]]; then
278
+ COMPREPLY=( $( compgen -W ' list' -- $cur ) )
279
+ fi
301
280
;;
302
281
esac
303
-
304
- COMPREPLY=( $( compgen -W ' bearer link media nametable node socket' -- $cur ) )
305
282
}
306
283
complete -F _tipc tipc
307
284
0 commit comments