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