Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[patch] groups with spaces



While most utilities to disallow groups with spaces, LDAP seems to have
no such qualms. Patch below to handle spaces in _groups. (Apologies if
it's mangled; my normal mail setup is currently blocked.)

_chgrp tries to be helpful and only suggest a user's groups for
effectively non-root users. Both groups and id -Gn separate groups by
spaces, so their output can't distinguish between two groups and
a single group with a space in it. Should there be a _user_groups type
that can

${${(f)"$(getent group $(id -G))"}%%:*}

along with whatever OS X and YP need?

- Matthew Martin



diff --git a/Completion/Unix/Type/_groups b/Completion/Unix/Type/_groups
index a562426..c5e5aaf 100644
--- a/Completion/Unix/Type/_groups
+++ b/Completion/Unix/Type/_groups
@@ -13,9 +13,9 @@ if ! zstyle -a ":completion:${curcontext}:" groups
groups; then
           : ${(A)_cache_groups:=${${(M)${(f)"$(_call_program groups
dscacheutil -q group)"}:#name*}##*: }}
         fi
       elif (( ${+commands[getent]} )); then
-        : ${(A)_cache_groups:=${${(s: :)$(_call_program groups getent
group 2>/dev/null)}%%:*}}
+        : ${(A)_cache_groups:=${${(f)"$(_call_program groups getent
group 2>/dev/null)"}%%:*}}
       else
-        : ${(A)_cache_groups:=${${${(s: :)$(</etc/group)}%%:*}:#+}}
+        : ${(A)_cache_groups:=${${${(f)"$(</etc/group)"}%%:*}:#+}}
     if (( ${+commands[ypcat]} )) &&
         tmp=$(_call_program groups ypcat group.byname 2>/dev/null); then
           _cache_groups+=( ${${(f)tmp}%%:*} ) # If you use YP



Messages sorted by: Reverse Date, Date, Thread, Author