aboutsummaryrefslogtreecommitdiff
path: root/extra/yash/files/doas
blob: ffe41bbc60c2da359f5ea38668f999b713195ada (plain)
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
33
34
35
36
37
38
39
40
41
42
# Completion script for the "doas" command.
function completion/doas {

	typeset OPTIONS ARGOPT PREFIX
	OPTIONS=( #>#
	"C:; specify the config file to parse and check its contents"
	"L; Clear any persisted authorizations from previous invocations"
	"n; Non interactive mode, fail if doas would prompt for password"
	"s; run \$SHELL"
	"u:; specify the user to change to"
	) #<#

	command -f completion//parseoptions
	case $ARGOPT in
	(-)
		command -f completion//completeoptions
		;;
	(C)
		complete -P "$PREFIX" -f
		;;
	(u)
		complete -P "$PREFIX" -u
		;;
	('')
		typeset i=2 edit=false
		while [ $i -le ${WORDS[#]} ]; do
			case ${WORDS[i]} in
				(--) break;;
				(-e) edit=true;;
			esac
			i=$((i+1))
		done
		if $edit; then
			complete -P "$PREFIX" -f
		else
			command -f completion//getoperands
			command -f completion//reexecute
		fi
		;;
	esac

}