walles / moar

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

Moar fails to STDOUT if content is less than a page with 'quit-if-one-screen' enabled #242

Closed Armadillidiid closed 2 months ago

Armadillidiid commented 2 months ago

With "quit-if-one-screen" arg enabled, Moar crashes and produces the following error:

Version: 1.24.2
LANG   : en_US.UTF-8
TERM   : xterm-kitty

GOOS    : linux
GOARCH  : amd64
Compiler: gc
NumCPU  : 12

panic: write /dev/stdout: file already closed [recovered]
    panic: write /dev/stdout: file already closed

goroutine 1 [running]:
main.main.func1()
    github.com/walles/moar/moar.go:793 +0x155
panic({0x5d5e7d16d800?, 0xc0003ee4b0?})
    runtime/panic.go:770 +0x132
github.com/walles/moar/twin.(*UnixScreen).write(...)
    github.com/walles/moar/twin/screen.go:198
github.com/walles/moar/twin.(*UnixScreen).showNLines(0xc000130d20, 0x1d, 0x40?)
    github.com/walles/moar/twin/screen.go:720 +0x385
github.com/walles/moar/twin.(*UnixScreen).ShowNLines(0xc000130d20?, 0x5d5e7d19cfa0?)
    github.com/walles/moar/twin/screen.go:687 +0x15
github.com/walles/moar/m.(*Pager).ReprintAfterExit(0xc000140000)
    github.com/walles/moar/m/pager.go:472 +0x58
main.startPaging.func1()
    github.com/walles/moar/moar.go:851 +0x52
main.startPaging(0x0?, {0x5d5e7d1a0218?, 0xc000130d20?}, 0x1?, 0x1?)
    github.com/walles/moar/moar.go:866 +0x6f
main.main()
    github.com/walles/moar/moar.go:818 +0x291

Here is my full arguments enabled in my .zprofile:

export MOAR='--statusbar=bold --no-linenumbers -style catppuccin-mocha --quit-if-one-screen'
walles commented 2 months ago

Please try with moar v1.26.0 or higher.

I was able to repro this with 1.24.2 (which you are running), but not with v1.26.0 (latest version).

Armadillidiid commented 2 months ago

I've upgraded to v1.26.0 and it's working now. Thank you