From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21776 invoked from network); 25 Jul 2005 09:15:56 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 25 Jul 2005 09:15:56 -0000 Received: (qmail 51155 invoked from network); 25 Jul 2005 09:15:48 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 25 Jul 2005 09:15:48 -0000 Received: (qmail 8732 invoked by alias); 25 Jul 2005 09:15:39 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9157 Received: (qmail 8712 invoked from network); 25 Jul 2005 09:15:37 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 25 Jul 2005 09:15:37 -0000 Received: (qmail 49796 invoked from network); 25 Jul 2005 09:15:37 -0000 Received: from sodans.usata.org (61.211.239.46) by a.mx.sunsite.dk with SMTP; 25 Jul 2005 09:15:33 -0000 Received: from [192.168.1.13] (KHP059134020054.ppp-bb.dion.ne.jp [59.134.20.54]) by sodans.usata.org (Postfix) with ESMTP id 9668DAADF; Mon, 25 Jul 2005 18:15:29 +0900 (JST) In-Reply-To: <3BF4526D-BFA6-46C7-A977-BD43DFAD4C07@jota.gsc.riken.go.jp> References: <1050724093315.ZM20733@candle.brasslantern.com> <3BF4526D-BFA6-46C7-A977-BD43DFAD4C07@jota.gsc.riken.go.jp> Mime-Version: 1.0 (Apple Message framework v733) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <10C0AB35-42EC-4270-8CC0-8ABDA5428A83@h8.dion.ne.jp> Cc: zsh-users@sunsite.dk Content-Transfer-Encoding: 7bit From: Motoi Washida Subject: Re: outputs of _users and _hosts to arrays Date: Mon, 25 Jul 2005 18:15:32 +0900 To: Wataru Kagawa X-Mailer: Apple Mail (2.733) X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.0.4 Hi Wataru, On 07/25/2005, at 14:18, Wataru Kagawa wrote: > Hi Bart, > > Thanks for the help. > After googling, I found out that _users extract usernames from /etc/ > passwd and _hosts extract hostnames from /etc/hosts. > > So, I can use parameter expansions like, > > users=( ${$( cat /etc/users | cut -d : -f 1,7 | grep -v "#" )//:*/} ) If you do that on Mac OS X, maybe you can't get even your name. ;-) The more general way is using $userdirs special variable. Load zsh/parameter module, % zmodload -i zsh/parameter and, % users=( $userdir[(I)*] ) I think you can also get user names by calling hash builtin function. But I had to rebuild named directory hash table to get expected results on some platforms. You might need to call this, % builtin hash -fd and get hash table entries, % users=( ${${(f)"$(builtin hash -d)"}%\=*} ) > hosts=( ${$( cat /etc/hosts | cut -d : -f 1,7 | grep -v "#" )//:*/} ) > > to get what I need. This has the same problem, but I don't know a better way well. Using some functions from Perl or some other language?