* Array parameter for supplementary groups?
@ 2011-01-18 18:27 Benjamin R. Haskell
2011-01-18 19:46 ` Dan Nelson
2011-01-18 20:05 ` Peter Stephenson
0 siblings, 2 replies; 3+ messages in thread
From: Benjamin R. Haskell @ 2011-01-18 18:27 UTC (permalink / raw)
To: Zsh Users
Is there an array parameter for the group IDs of the current user? Am I
overlooking it?
Under Cygwin under Windows 7, right-click run-as-administrator adds some
supplementary groups, but the user is otherwise indistinguishable,
AFAICT. I'd like to be able to do something like:
(( $+groups[(Re)0] )) && { do stuff for admin-style prompt }
without resorting to parsing the output of `id`. (examples:)
running as normal:
uid=12522(bhaskell) gid=10513(Domain Users) groups=10513(Domain Users),545(Users)
running as admin:
uid=12522(bhaskell) gid=10513(Domain Users) groups=10513(Domain Users),0(root),544(Administrators),545(Users)
(I just dislike parsing when it's not necessary.)
--
Best,
Ben
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Array parameter for supplementary groups?
2011-01-18 18:27 Array parameter for supplementary groups? Benjamin R. Haskell
@ 2011-01-18 19:46 ` Dan Nelson
2011-01-18 20:05 ` Peter Stephenson
1 sibling, 0 replies; 3+ messages in thread
From: Dan Nelson @ 2011-01-18 19:46 UTC (permalink / raw)
To: Benjamin R. Haskell; +Cc: Zsh Users
In the last episode (Jan 18), Benjamin R. Haskell said:
> Is there an array parameter for the group IDs of the current user? Am I
> overlooking it?
>
> Under Cygwin under Windows 7, right-click run-as-administrator adds some
> supplementary groups, but the user is otherwise indistinguishable,
> AFAICT. I'd like to be able to do something like:
>
> (( $+groups[(Re)0] )) && { do stuff for admin-style prompt }
>
> without resorting to parsing the output of `id`. (examples:)
Parsing the output of "groups" or "id -G" is simpler, btw. A builtin with
this info would be nice, though :)
--
Dan Nelson
dnelson@allantgroup.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Array parameter for supplementary groups?
2011-01-18 18:27 Array parameter for supplementary groups? Benjamin R. Haskell
2011-01-18 19:46 ` Dan Nelson
@ 2011-01-18 20:05 ` Peter Stephenson
1 sibling, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2011-01-18 20:05 UTC (permalink / raw)
To: Zsh Users
On Tue, 18 Jan 2011 13:27:53 -0500 (EST)
"Benjamin R. Haskell" <zsh@benizi.com> wrote:
> Is there an array parameter for the group IDs of the current user? Am I
> overlooking it?
No, but if you speak Unreadable you can create one quite quickly...
idgroups() {
emulate -L zsh
setopt extendedglob
typeset -gA groups
groups=(
${=${${(s.,.)${${$(id):#^groups=*}##groups=}}/(#b)(*)\((*)\)/$match[2]\
$match[1]}}
)
}
Of course if we had discipline functions blah blah blah.
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-01-18 20:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-18 18:27 Array parameter for supplementary groups? Benjamin R. Haskell
2011-01-18 19:46 ` Dan Nelson
2011-01-18 20:05 ` Peter Stephenson
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).