Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: A conditional test to see whether a function is loaded?
- X-seq: zsh-users 11537
- From: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: A conditional test to see whether a function is loaded?
- Date: Sat, 09 Jun 2007 14:45:20 +0200
- In-reply-to: <4B761D89-02BE-4F7F-87C6-37331C89786B@xxxxxxxxxxxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <4B761D89-02BE-4F7F-87C6-37331C89786B@xxxxxxxxxxxxxxxxxx>
William Scott <wgscott@xxxxxxxxxxxxxxxxxx>:
> Hi everyone:
>
> I want to write a shell script that (among other things) tests to see if a
> function foo is loaded.
>
> Is there something analogous to [[ -x $(which foo) ]] that would test
> specifically for a loaded function, or an autoloadable function, rather
> than an executable file?
Try this:
[snip]
zsh% [[ -n ${functions[promptinit]} ]] && echo yay || echo nay
nay
zsh% autoload -U promptinit
zsh% [[ -n ${functions[promptinit]} ]] && echo yay || echo nay
yay
[snap]
Regards, Frank
--
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
-- RFC 1925
Messages sorted by:
Reverse Date,
Date,
Thread,
Author