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

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



fREW <frioux@xxxxxxxxx>:
> On 6/9/07, William Scott <wgscott@xxxxxxxxxxxxxxxxxx> wrote:
>> Frank Terbeck wrote:
>>
>> > zsh% [[ -n ${functions[promptinit]} ]] && echo yay || echo nay
>>
>
> I have a similar question.  Is there a shorter, more zsh-y way to do:
> [[ -x `which aptitude` ]]

I'd write [[ -x $(which aptitude) ]], which means the same, but looks
better, IMHO. :-)

> Obviously replace aptitude with any program.  I tried [[ -x =aptitude
> ]] but that gives error messages if it doesn't exist.

The reason this fails is, that the shell tries to expand =aptitude,
but if aptitude is not there, that fails, thus the error message.

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