From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: zsh users mailing list <zsh-users@sunsite.auc.dk>
Subject: Re: autoloading questions
Date: Fri, 15 Oct 1999 09:18:01 +0000 [thread overview]
Message-ID: <991015091801.ZM22985@candle.brasslantern.com> (raw)
In-Reply-To: <19991014165452.A31729@thelonious.new.ox.ac.uk>
On Oct 14, 4:54pm, Adam Spiers wrote:
} Subject: autoloading questions
}
} 1. What's the best way of checking whether an autoload of a function
} will succeed? (I mean the actual loading, rather than the
} invocation of the `autoload' built-in.)
I can't think of anything except
function testauto {
emulate -L zsh
local f
f=( $^fpath/$1(N) )
[[ -n $f[1] ]] && $ZSH_NAME -ns < $f[1]
}
That requires forking an extra shell, though, and it's still nothing
more than a syntax check.
} 2. How can I manually cause an autoloaded function to be loaded
} without actually running it
Try this:
function loadauto {
emulate -L zsh
local f
f=( $^fpath/$1(N) )
eval "function $1 {
$(< $f[1])
}"
}
(You can replace $(< $f[1]) with $mapfile[$f[1]] if you use that module,
but $(<...) is already a non-forking special-case.)
Actually, I guess calling loadauto would tell you whether the autoload
succeeds, so it sort of answers both questions ....
BTW, this question made me notice that it's not a good idea to do
autoload fun
zmodload parameter
noglob vared functions[fun]
unless you're very careful about whether you press enter.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
next prev parent reply other threads:[~1999-10-15 9:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-10-14 15:54 Adam Spiers
1999-10-15 9:18 ` Bart Schaefer [this message]
1999-10-15 9:50 Sven Wischnowsky
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=991015091801.ZM22985@candle.brasslantern.com \
--to=schaefer@candle.brasslantern.com \
--cc=zsh-users@sunsite.auc.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).