walles / moar

Moar is a pager. It's designed to just do the right thing without any configuration.
Other
585 stars 17 forks source link

Options are not used via environment variables with "bat" #183

Closed dsully closed 5 months ago

dsully commented 5 months ago

When using bat with the following options:

export PAGER=moar
export MOAR="-statusbar bold -no-linenumbers -no-clear-on-exit -style nord -colors 16M -wrap -quit-if-one-screen"

And running: bat <small-file> that should cause the -quit-if-one-screen option to kick in, it doesn't and paging occurs.

If I run moar <small-file> directly, then it works.

If I run: bat --pager="'$PAGER $MOAR'" <small-file> it also works.

TBH, I'm not sure if this is a moar issue or a bat issue or somewhere in between.

walles commented 5 months ago

One experiment would be to add --help to the options in MOAR and see what happens:

PAGER=moar MOAR=--help bat small-file

There are two possible outcomes:

  1. The expected one is that moar shows its help text. This means that moar successfully gets the value of the MOAR variable.
  2. The contents of small-file is shown. This means that moar does not get access to the MOAR variable.

1 would mean that moar and -quit-if-one-screen doesn't work properly for some reason. 2 could mean that bat either doesn't launch moar at all, or that it somehow / for some reason hides the MOAR variable from moar.

dsully commented 5 months ago

Just tested and the first outcome is what I see - the help output of moar.

walles commented 5 months ago

I was able to repro this locally.

Seems like -quit-if-one-screen doesn't work for piped input, and it should.

Thanks for reporting, since I'm not using neither bat nor -quit-if-one-screen I would never have seen this. Will look into it.

walles commented 5 months ago

Fix released: https://github.com/walles/moar/releases/tag/v1.22.3

dsully commented 5 months ago

Thanks for the quick fix!