From: Lloyd Zusman <ljz@asfast.com>
To: zsh-users@sunsite.dk
Subject: Re: Emulating 'locate'
Date: Sat, 04 Oct 2003 19:18:19 -0400 [thread overview]
Message-ID: <m365j4oamc.fsf@asfast.com> (raw)
In-Reply-To: <1031004224016.ZM29064@candle.brasslantern.com> (Bart Schaefer's message of "Sat, 4 Oct 2003 22:40:16 +0000")
Bart Schaefer <schaefer@brasslantern.com> 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@asfast.com
next prev parent reply other threads:[~2003-10-04 23:18 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20031001221753.GA23189@DervishD>
[not found] ` <1031002023639.ZM22046@candle.brasslantern.com>
2003-10-02 8:03 ` DervishD
2003-10-02 14:29 ` Bart Schaefer
2003-10-02 15:53 ` DervishD
2003-10-02 17:08 ` Oliver Kiddle
2003-10-02 19:27 ` DervishD
2003-10-03 16:22 ` Lloyd Zusman
2003-10-04 10:48 ` DervishD
2003-10-04 13:48 ` Lloyd Zusman
2003-10-04 15:12 ` DervishD
2003-10-04 17:05 ` Lloyd Zusman
2003-10-04 21:35 ` DervishD
2003-10-04 16:37 ` Bart Schaefer
2003-10-04 19:33 ` Lloyd Zusman
2003-10-04 21:29 ` DervishD
2003-10-04 22:40 ` Bart Schaefer
2003-10-04 23:18 ` Lloyd Zusman [this message]
2003-10-05 15:57 ` Bart Schaefer
2003-10-06 13:37 ` Lloyd Zusman
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=m365j4oamc.fsf@asfast.com \
--to=ljz@asfast.com \
--cc=zsh-users@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).