zsh-workers
 help / color / mirror / code / Atom feed
From: Matthew Martin <phy1729@gmail.com>
To: zsh-workers@zsh.org
Subject: [patch] groups with spaces
Date: Sun, 22 Nov 2015 17:15:39 -0600	[thread overview]
Message-ID: <CAGnh9tBw7NuS8m4QBhtMKyNF79XyO2JaCR7gtNK9JfXvWEVqUA@mail.gmail.com> (raw)

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


                 reply	other threads:[~2015-11-22 23:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGnh9tBw7NuS8m4QBhtMKyNF79XyO2JaCR7gtNK9JfXvWEVqUA@mail.gmail.com \
    --to=phy1729@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).