Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [[ -x =command ]]
- X-seq: zsh-users 12028
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: Matthew Wozniski <godlygeek@xxxxxxxxx>
- Subject: Re: [[ -x =command ]]
- Date: Wed, 17 Oct 2007 13:52:42 +0100
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <20071017113432.GA13054@mastermind>
- Mail-followup-to: Matthew Wozniski <godlygeek@xxxxxxxxx>, 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> <20071017094414.GA5383@xxxxxxxxxxxxxxx> <20071017113432.GA13054@mastermind>
On Wed, Oct 17, 2007 at 07:34:32AM -0400, Matthew Wozniski wrote:
> On Wed, Oct 17, 2007 at 10:44:14AM +0100, Stephane Chazelas wrote:
> > 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.
>
> Hm. `command -v more' and `$commands[more]' aren't equivalent, it
> seems.
>
> mastermind% echo $commands[ls]
> /bin/ls
> mastermind% command -v ls
> alias ls='ls --color=auto -B'
>
> So, just for the sake of argument, if one were to have aliased `most'
> to `less' on a machine that didn't have most, the first form would
> work properly, but the second would result in a false positive and
> fail when an application tried to use $PAGER, since no alias expansion
> would be performed.
[...]
You're right,
You could use whence -p instead, but then it would no longer be
portable.
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author