Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Emulating 'locate'
- X-seq: zsh-users 6641
- From: Lloyd Zusman <ljz@xxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Emulating 'locate'
- Date: Sat, 04 Oct 2003 19:18:19 -0400
- In-reply-to: <1031004224016.ZM29064@xxxxxxxxxxxxxxxxxxxxxxx> (Bart Schaefer's message of "Sat, 4 Oct 2003 22:40:16 +0000")
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20031001221753.GA23189@DervishD> <1031002023639.ZM22046@xxxxxxxxxxxxxxxxxxxxxxx> <20031002080358.GA23230@DervishD> <m365j6watm.fsf@xxxxxxxxxx> <20031004104844.GA50@DervishD> <m3oewxru4k.fsf@xxxxxxxxxx> <1031004163727.ZM28731@xxxxxxxxxxxxxxxxxxxxxxx> <m3isn4ol1q.fsf@xxxxxxxxxx> <1031004224016.ZM29064@xxxxxxxxxxxxxxxxxxxxxxx>
- Reply-to: ljz@xxxxxxxxxx
- Sender: Lloyd Zusman <ljz@xxxxxxxxxx>
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> writes:
> On Oct 4, 3:33pm, Lloyd Zusman wrote:
> }
> } [ ... ]
> }
> For certain searches, "find -depth" might actually be faster. Zsh
> always does breadth-first globbing, even when asked to sort the final
> results depth-first.
I guess that comes into play when I want to find something that happens
to be buried deep inside of a directory tree, where the parents directories
have lots of files.
> } [ ... ]
> }
> } Well, using this alias causes the argv indices to be off by one in the
> } shell function: $0 becomes 'noglob', argv[1] becomes 'xlocate', etc.
>
> If you're seeing that, then you've accidentally created a function named
> "noglob" that has the same body as "xlocate". Try this:
>
> alias foo='bar foo'
> foo() { echo $0 }
> functions bar
> functions foo
>
> Note that "foo()" is considered to be "in the command position" and thus
> the alias expands and you get
>
> bar foo () { echo $0 }
>
> which defines two functions, "bar" and "foo" with identical bodies. I'd
> wager that you created the alias, then changed the definition of xlocate,
> and ended up with a function named "noglob".
Yep. That's exactly what happened. Thank you. I kept re-invoking
". /etc/zshrc" to test some changes to my function as I was developing
it. The alias command "alias xlocate='noglob xlocate'" was then in
effect the next time I sourced /etc/zshrc.
Therefore, prior to the function definition, I now do this:
{ unalias xlocate; unfunction xlocate } 2>/dev/null
But besides that, would another way to prevent this problem be to always
define functions with "function foo" instead of "foo()"?
--
Lloyd Zusman
ljz@xxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author