diff options
author | dana <dana@dana.is> | 2018-06-04 10:04:27 -0500 |
---|---|---|
committer | Oliver Kiddle <okiddle@yahoo.co.uk> | 2018-06-07 18:19:55 +0200 |
commit | 64ef1eddfd4fa79a0720945e189cf7c3a44bde9c (patch) | |
tree | 9237ef4615c0643b783d5fac4f007f9cb4fc693d /Completion/Unix/Command/_chroot | |
parent | 594f2ff06e85bf27b154dd703ee3b2dd7f168bc0 (diff) | |
download | zsh-64ef1eddfd4fa79a0720945e189cf7c3a44bde9c.tar.gz zsh-64ef1eddfd4fa79a0720945e189cf7c3a44bde9c.tar.xz zsh-64ef1eddfd4fa79a0720945e189cf7c3a44bde9c.zip |
42931: completion for several utilities especially for checksums across a variety of systems
Diffstat (limited to 'Completion/Unix/Command/_chroot')
-rw-r--r-- | Completion/Unix/Command/_chroot | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/Completion/Unix/Command/_chroot b/Completion/Unix/Command/_chroot new file mode 100644 index 000000000..516992694 --- /dev/null +++ b/Completion/Unix/Command/_chroot @@ -0,0 +1,53 @@ +#compdef chroot gchroot + +local variant ret=1 +local -a context line state state_descr args +local -A opt_args + +_pick_variant -r variant gnu='Free Soft' unix --version + +variant+=-$OSTYPE + +case $variant in + gnu-*) + args=( + '(: -)--help[display help information]' + '(: -)--version[display version information]' + '--groups=[specify supplemental group memberships]: :_sequence -s , _groups' + '--userspec=[specify user and group to run process as]: :->userspecs' + '--skip-chdir[do not change working directory to /]' + ) + ;; + *-openbsd*) + args=( + '-u+[specify user to run process as]: :_users' + '-g+[specify group to run process as, and supplemental group memberships]: :_sequence -s , _groups' + ) + ;; + *-(darwin|dragonfly|freebsd|netbsd)*) + args=( + '-u+[specify user to run process as]: :_users' + '-g+[specify group to run process as]: :_groups' + '-G+[specify supplemental group memberships]: :_sequence -s , _groups' + ) + ;; +esac + +args+=( '1:new root directory:_directories' '*:::command:_normal' ) + +_arguments -s -S : $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 |