future-install-scripts/completion/zsh/_arch-chroot
Emil Velikov aeaecf5ae5 arch-chroot: add option to preserve the chroot resolv.conf
There is a comprehensive inline comment about why we're touching the
chroot resolv.conf. Although it does not consider the cases where:
 - the link may be broken for specific reasons, and/or
 - working resolver within the chroot is not wanted

v2:
 - flip the condition check

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2023-03-29 21:28:31 +01:00

32 lines
778 B
Plaintext

#compdef arch-chroot
# NOTE: nearly everything here is borrowed from the chroot completion
local -a args=(
'(-h --help)'{-h,--help}'[display help]'
'-N[Run in unshare mode as a regular user]'
'-u[The non-root user and optional group to use]: :->userspecs'
'-r[Do not change the resolv.conf within the chroot]'
'1:new root directory:_directories'
'*:::command:_normal'
)
local ret=1
_arguments $args && ret=0
# @todo user:group specs are probably used often enough to justify making a type
# function for this (see also `chown`, `cpio`, `rsync`, ...)
[[ $state == userspecs ]] &&
if compset -P '*:*:'; then
ret=1
elif compset -P '*:'; then
_groups && ret=0
elif compset -S ':*'; then
_users && ret=0
else
_users -qS : && ret=0
fi
return ret