From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24202 invoked from network); 16 Dec 2005 00:00:02 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 16 Dec 2005 00:00:02 -0000 Received: (qmail 27011 invoked from network); 15 Dec 2005 23:59:56 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 15 Dec 2005 23:59:56 -0000 Received: (qmail 528 invoked by alias); 15 Dec 2005 23:59:53 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22086 Received: (qmail 519 invoked from network); 15 Dec 2005 23:59:52 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 15 Dec 2005 23:59:52 -0000 Received: (qmail 26711 invoked from network); 15 Dec 2005 23:59:52 -0000 Received: from pop06.mail.atl.earthlink.net (207.69.200.40) by a.mx.sunsite.dk with SMTP; 15 Dec 2005 23:59:50 -0000 Received: from h-68-166-24-91.atlngahp.dynamic.covad.net ([68.166.24.91] helo=shazam.localnet) by pop06.mail.atl.earthlink.net with esmtp (Exim 3.36 #10) id 1En30m-0002Lp-00 for zsh-workers@sunsite.dk; Thu, 15 Dec 2005 18:59:48 -0500 Received: from jhankins by shazam.localnet with local (Exim 3.36 #1 (Debian)) id 1En30l-0001oe-00 for ; Thu, 15 Dec 2005 17:59:47 -0600 From: Jonathan Hankins To: zsh-workers@sunsite.dk Subject: Re: Globbing feature suggestion References: <87irtt4uno.fsf@shazam.localnet> <1051213041649.ZM21953@candle.brasslantern.com> <871x0ge5ge.fsf@shazam.localnet> <1051215043452.ZM3906@candle.brasslantern.com> Date: Thu, 15 Dec 2005 17:59:47 -0600 In-Reply-To: <1051215043452.ZM3906@candle.brasslantern.com> (Bart Schaefer's message of "Thu, 15 Dec 2005 04:34:52 +0000") Message-ID: <87lkylewss.fsf@shazam.localnet> User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: Jonathan Hankins Oops -- meant to follow-up to the list -- still learning my way around Gnus :-) Bart Schaefer writes: > [zsh-workers copied] > > On Dec 13, 9:13pm, Jonathan Hankins wrote: > } > } > -nogroup is the glob qualifier (e['stat -s -A reply +gid $REPLY; > } > reply=(${${(M)reply:#<->}/<->/$REPLY})']) > } This doesn't work for me -- stat -s returns '???' when there is no > } pw/grent for the the u/gid. > > Urk. Sorry about that; I don't actually *have* any files with unknown > uid/gid on my system, but I had assumed "stat" would return the > numeric ID in the absence of a name, the way "ls -l" does. I didn't either, but it gave me the chance to discover that chown(1) on my linux box works if you specify a numeric ID, even if there is no corresponding pw/grent. Who would have guessed? > In fact I think it's pretty darn useless to return '???' for all > unknown IDs, as if they were equivalent. Would anyone seriously > object if that were changed? I thought the same when I saw it. I guess it _does_ give you a way to tell when a user or group does _not_ exist. > } It works if I change it to: > } > } -nogroup is the glob qualifier (e['stat -s -A reply +gid $REPLY; > } reply=(${${(M)reply:#???}/???/$REPLY})']) > > As that's written, ??? is a pattern matching any three characters, so > if you have any 3-letter usernames on your system, that would > improperly include them. You need \?\?\? instead. Yeah, I had the backslashes at first, then I tried without it and it still matched, so my brain shut off for a minute and I forgot that (e::) re-evaluates its argument. Speaking of nearly-useless globbing, here is a function to glob all files that are group-owned by _any_ of your groups, including primary (login) GID. Contrast with (G): -- # $Id: is_gid_file,v 1.3 2005/12/14 00:21:38 jhankins Exp $ # Compare gid of file specified in $REPLY to all of user's groups. Use like: # # % print *(+cmp_gid) # # to list all files group-owned by _any_ of user's groups. Compare to: # # % print *(G) # # which only lists files owned by user's primary group. # emulate -L zsh zmodload -i zsh/stat typeset -ag _gids if [[ $#_gids < 1 ]]; then _gids=($(id -G)) fi [[ -n ${(M)_gids:#$(stat +gid -- $REPLY)} ]] -- Thanks, -Jonathan Hankins -- +------------------+-----------------------------------------------------+ |Jonathan Hankins | jonathan-hankins@mindspring.com | +------------------+-----------------------------------------------------+