Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Emulating 'locate'
- X-seq: zsh-users 6630
- From: DervishD <raul@xxxxxxxxxxxx>
- To: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- Subject: Re: Emulating 'locate'
- Date: Thu, 2 Oct 2003 21:27:49 +0200
- Cc: Zsh Users <zsh-users@xxxxxxxxxx>
- In-reply-to: <13972.1065114509@xxxxxxxxxxx>
- Mail-followup-to: Oliver Kiddle <okiddle@xxxxxxxxxxx>, Zsh Users <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Organization: Pleyades
- References: <20031001221753.GA23189@DervishD> <1031002023639.ZM22046@xxxxxxxxxxxxxxxxxxxxxxx> <20031002080358.GA23230@DervishD> <1031002142928.ZM22765@xxxxxxxxxxxxxxxxxxxxxxx> <20031002155306.GA26812@DervishD> <13972.1065114509@xxxxxxxxxxx>
Hi Oliver :))
* Oliver Kiddle <okiddle@xxxxxxxxxxx> dixit:
> > locate () {
[...]
> What? So instead of zsh barfing on no matches, your script goes and
> does the barfing for it: if I'm not missing the plot entirely here
> you've basically just undone the effect of the nullglob options
> manually.
Not exactly. I've replaced a message like 'zsh: no matches found:
/**/*whatever*...' by a simple 'Sorry I didn't found whatever'. This
*is* intended, because I was writing a locate emulation for end users
(just for fun, I must admit, but for end users...). I didn't had in
mind using this function in pipelines or complex commands.
> You'd only want to do this if this locate() function is really part of
> something bigger and the error message is indicating something really
> is wrong. In which case you might want to send it to stderr with >&2.
You are completely right.
> There are good reasons why commands like locate and grep don't print
> silly messages when nothing is found.
I can think of one right now: if you use it in a command
substitution, you really don't want your file list, for example,
being 'grep: arse! cannot find your effin regex'... Yes, obviously
the less I could do with the function above is redirecting the
message to stderr, my mistake O:))
Anyway I don't use 'locate' in pipelines or command substitution,
so I didn't think about this situation. Thanks for pointing.
> The one useful improvement you
> might make would be to return 1 if no matches are found.
Yes, this would be a good idea, thanks a lot :)) And I must admit
- painfully ;)) - that it would be even better than a message.
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author