Re: [PATCH (topgit) 1/2] Implement setup_pager just like in git
- From
Thomas Rast <trast@student.ethz.ch>
- Date
- Jan 7, 2009, 12:24 UTC
- Message-ID
- <200901071324.57222.trast@student.ethz.ch>
- In-Reply-To
- <20090107112754.GA15158@roro3>
Kirill Smelkov wrote:
Show 14 quoted lines
> On Tue, Jan 06, 2009 at 09:32:03PM +0100, martin f krafft wrote:
> > I find this very confusing. Why not simply
> >
> > TG_PAGER="${GIT_PAGER:-}"
> > TG_PAGER="${TG_PAGER:-$PAGER}"
> >
> > ?
>
> I find it confusing too, but this is needed because they usually do
> something like this
>
> $ GIT_PAGER='' <some-git-command>
>
> to force it to be pagerless.[...]
> So I think it would be better to preserve the same semantics for `tg > patch` callers, though it's a pity that it's hard (maybe I'm wrong ?) to > see whether an env var is unset.
Admittedly I haven't really studied your patch, but the ${} constructs can in fact tell empty from unset:
$ EMPTY=
$ unset UNDEFINED
$ echo ${UNDEFINED-foo}
foo
$ echo ${UNDEFINED:-foo}
foo
$ echo ${EMPTY-foo} $ echo ${EMPTY:-foo}
foo'man bash' indeed says
When not performing substring expansion, bash tests for a parameter that is unset or null; omitting the colon results in a test only for a parameter that is unset.
So I suppose you could use
${GIT_PAGER-${PAGER-less}}or similar.
--
Thomas Rast
trast@{inf,student}.ethz.ch