forked from OpenIndiana/openindiana-completions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dladm
31 lines (27 loc) · 1.2 KB
/
dladm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# OpenIndiana dladm(1M) completion -*- shell-script -*-
# ------------------------------------------------------------------------------
# Copyright (c) 2012, Rob Gulewich <[email protected]>
# Copyright (c) 2018, Michal Nowak <[email protected]>
_dladm()
{
local cur prev
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [[ ${prev} == 'dladm' ]]; then
local cmds="$(dladm 2>&1 | awk '/^ / { print $1 }')"
COMPREPLY=( $(compgen -W "${cmds}" -- ${cur}) )
elif [[ ${prev} =~ 'delete-vnic' ]]; then
# Redirect stderr to /dev/null not to polute console, e.g.:
# dladm: could not open /dev/dld: object not found
local vnics="$(dladm show-vnic -p -o link 2> /dev/null)"
COMPREPLY=( $(compgen -W "${vnics}" -- ${cur}) )
elif [[ ${prev} =~ 'delete-etherstub' ]]; then
# Redirect stderr to /dev/null not to polute console, e.g.:
# dladm: could not open /dev/dld: object not found
local stubs="$(dladm show-etherstub -p 2> /dev/null)"
COMPREPLY=( $(compgen -W "${stubs}" -- ${cur}) )
fi
}
complete -F _dladm dladm
# ex: filetype=sh
# vim: tabstop=2 shiftwidth=2 expandtab smartindent