| 1 |
#compdef arch-chroot |
| 2 |
|
| 3 |
# NOTE: nearly everything here is borrowed from the chroot completion |
| 4 |
local -a args=( |
| 5 |
'(-h --help)'{-h,--help}'[display help]' |
| 6 |
'-N[Run in unshare mode as a regular user]' |
| 7 |
'-u[The non-root user and optional group to use]: :->userspecs' |
| 8 |
'-r[Do not change the resolv.conf within the chroot]' |
| 9 |
'1:new root directory:_directories' |
| 10 |
'*:::command:_normal' |
| 11 |
) |
| 12 |
|
| 13 |
local ret=1 |
| 14 |
|
| 15 |
_arguments $args && ret=0 |
| 16 |
|
| 17 |
# @todo user:group specs are probably used often enough to justify making a type |
| 18 |
# function for this (see also `chown`, `cpio`, `rsync`, ...) |
| 19 |
|
| 20 |
[[ $state == userspecs ]] && |
| 21 |
if compset -P '*:*:'; then |
| 22 |
ret=1 |
| 23 |
elif compset -P '*:'; then |
| 24 |
_groups && ret=0 |
| 25 |
elif compset -S ':*'; then |
| 26 |
_users && ret=0 |
| 27 |
else |
| 28 |
_users -qS : && ret=0 |
| 29 |
fi |
| 30 |
|
| 31 |
return ret |