Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [[ -x =command ]]
- X-seq: zsh-users 12021
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: Atom Smasher <atom@xxxxxxxxxxx>
- Subject: Re: [[ -x =command ]]
- Date: Wed, 17 Oct 2007 10:44:14 +0100
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <20071016214100.62242.qmail@xxxxxxxxxxx>
- Mail-followup-to: Atom Smasher <atom@xxxxxxxxxxx>, zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20071016210548.26560.qmail@xxxxxxxxxxx> <20071016211319.GA2910@xxxxxxxxxxxxxxx> <20071016214100.62242.qmail@xxxxxxxxxxx>
On Wed, Oct 17, 2007 at 10:40:59AM +1300, Atom Smasher wrote:
> On Tue, 16 Oct 2007, Frank Terbeck wrote:
>
>>> b) if not, what's the correct way to test if a command exists in the
>>> PATH?
>>
>> [[ -x $(which most) ]] && echo yay || echo nay
> =============
>
> cool, thanks...
>
> [[ -x $(whence -p most) ]] && export PAGER=$(whence -p most)
[...]
zmodload -i zsh/parameters
export PAGER=\
${commands[most]:-\
${commands[less]:-\
${commands[w3m]:-\
${commands[pager]:-\
more}}}}
or, portably:
for PAGER in most less w3m pager more; do
command -v "$PAGER" > /dev/null 2>&1 && break
done
export PAGER
as I don't think you need the full path in $PAGER.
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author