From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh <zsh-workers@sunsite.dk>
Subject: Re: Emulating 'locate'
Date: Thu, 2 Oct 2003 02:36:39 +0000 [thread overview]
Message-ID: <1031002023639.ZM22046@candle.brasslantern.com> (raw)
In-Reply-To: <20031001221753.GA23189@DervishD>
[We should just go off and have our own little mailing list.]
On Oct 2, 12:17am, DervishD wrote:
}
} Well, I suppose that slashes must be
} matched explicitly (that is what ** is for...)
No, that is what **/ is for. Each **/ (but not /**) triplet is replaced
by zero or more levels of hierarchy. It's the trailing slash that makes
** magical; without it ** is just like *.
Actually to be entirely accurate, not _every_ **/ triplit is so replaced;
the **/ has to be the only thing in one level of hierarchy, i.e., it can't
be foo**/ either.
} Let do 'locate ir2'. The list of output files is the same as
} 'locate ir3' (well, it outputs a couple of dirs more). But if I do
} 'print -l /**/*ir2*/**' I only get '/dir1/dir2/dir3' :((( In fact,
} adding more ** doesn't work: 'print /**/*ir2*/**/**' just outputs
} '/dir1/dir2/ /dir1/dir2/dir3/ /dir1/dir2/dir3'
That last should have done almost what you wanted, except the final *
is redundant. I suspect you really did
print /**/*ir2*/*/**
^^^ Note only one star here
when you meant
print /**/*ir2*/**/*
But that's still not sufficient, because it requires that *ir2* be only
an intervening directory and not the last file or directory in the path.
For that you have to use brace expansion, because you can't mix **/ and
any other form of alternation:
print -l /**/*ir2*{,/**/*}
So "locate" would be e.g.
locate() { print -l /**/*${^*}*{,/**/*} }
(You really ought to be sending these questions to -users, not -workers.)
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
prev parent reply other threads:[~2003-10-02 2:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-01 22:17 DervishD
2003-10-02 2:36 ` Bart Schaefer [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=1031002023639.ZM22046@candle.brasslantern.com \
--to=schaefer@brasslantern.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).