Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: A conditional test to see whether a function is loaded?



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