Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [[ -x =command ]]
- X-seq: zsh-users 12019
- From: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: [[ -x =command ]]
- Date: Tue, 16 Oct 2007 23:13:19 +0200
- In-reply-to: <20071016210548.26560.qmail@xxxxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20071016210548.26560.qmail@xxxxxxxxxxx>
Atom Smasher <atom@xxxxxxxxxxx>:
> as i understand the documentation, this should either return 0 or !0
> depending on whether a command "foo" can be found in the path:
> [[ -x =foo ]]
>
> but if =foo can't be found, it craps out.
>
> i've got this in my ~/.zshrc:
> [[ -x =most ]] && export PAGER=most
>
> and i would expect that if "most" isn't in my path, nothing would happen
> (nothing, in this case, meaning the PAGER variable remains unset)...
> instead what actually happens that processing of ~/.zshrc dies with an
> error. not good!
>
> so....
> a) should that work the way i'm doing it?
No.
If 'most' is not in $path, =most can not be expanded, which will cause
the error.
> b) if not, what's the correct way to test if a command exists in the PATH?
[[ -x $(which most) ]] && echo yay || echo nay
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