From: Jonathan Hankins <jonathan-hankins@mindspring.com>
To: zsh-workers@sunsite.dk
Subject: Re: Globbing feature suggestion
Date: Thu, 15 Dec 2005 17:59:47 -0600 [thread overview]
Message-ID: <87lkylewss.fsf@shazam.localnet> (raw)
In-Reply-To: <1051215043452.ZM3906@candle.brasslantern.com> (Bart Schaefer's message of "Thu, 15 Dec 2005 04:34:52 +0000")
Oops -- meant to follow-up to the list -- still learning my way around
Gnus :-)
Bart Schaefer <schaefer@brasslantern.com> 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 |
+------------------+-----------------------------------------------------+
prev parent reply other threads:[~2005-12-16 0:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87irtt4uno.fsf@shazam.localnet>
[not found] ` <1051213041649.ZM21953@candle.brasslantern.com>
[not found] ` <871x0ge5ge.fsf@shazam.localnet>
2005-12-15 4:34 ` Bart Schaefer
2005-12-15 10:45 ` Peter Stephenson
2005-12-15 23:59 ` Jonathan Hankins [this message]
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=87lkylewss.fsf@shazam.localnet \
--to=jonathan-hankins@mindspring.com \
--cc=zsh-workers@sunsite.dk \
/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).