Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Emulating 'locate'
- X-seq: zsh-users 6628
- From: DervishD <raul@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Emulating 'locate'
- Date: Thu, 2 Oct 2003 17:53:06 +0200
- Cc: Zsh Users <zsh-users@xxxxxxxxxx>
- In-reply-to: <1031002142928.ZM22765@xxxxxxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, 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>
Hi Bart :)
* Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> dixit:
> } > locate() { print -l /**/*${^*}*{,/**/*} }
> You might want:
> locate() {
> setopt localoptions nullglob nocshnullglob
> print -l /**/*${^*}*{,/**/*}
> }
> Do you see why?
Well, the localoptions is for making option changes local, so
options are restored ;) The nullglob and nocshnullglob are for making
sure that zsh won't barf if no matches are found. In fact, something
like this would be better for users:
locate () {
setopt localoptions nullglob nocshnullglob rcexpandparam
local -a matches
matches=(/**/*${*}*{,/**/*})
if [[ -z "$matches" ]]
then
print "Sorry, no matches found for '$*'"
else
print -l $matches
fi
}
Thanks for your help :))
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