forked from OpenIndiana/openindiana-completions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pfexec
32 lines (27 loc) · 952 Bytes
/
pfexec
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
32
# OpenIndiana pfexec(1) completion -*- shell-script -*-
# ------------------------------------------------------------------------------
# Copyright (c) 2018, Michal Nowak <[email protected]>
_pfexec()
{
local cur prev i
_init_completion || return
for (( i=1; i <= COMP_CWORD; i++ )); do
if [[ ${COMP_WORDS[i]} != -* ]]; then
local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
local root_command=${COMP_WORDS[i]}
_command_offset $i
return
fi
[[ ${COMP_WORDS[i]} == "-P" ]] && ((i++))
done
# Get profile names from profile description database, see prof_attr(4)
if [[ "${prev}" == "-P" ]]; then
COMPREPLY=( $(compgen -W "$(awk -F: '/^[A-Z]/ {print $1}' /etc/security/prof_attr)" -P \' -S \' -- "${cur}") )
fi
if [[ "${cur}" == -* ]]; then
COMPREPLY=( "-P" )
fi
}
complete -F _pfexec pfexec
# ex: filetype=sh
# vim: tabstop=2 shiftwidth=2 expandtab smartindent