# OpenIndiana dladm(1M) completion -*- shell-script -*- # ------------------------------------------------------------------------------ # Copyright (c) 2012, Rob Gulewich # Copyright (c) 2018, Michal Nowak _dladm() { local cur prev cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" if [[ ${prev} == 'dladm' ]]; then local cmds="$(dladm help 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