walles/moar

Program crashes when sudo-prefixed command which requires password entry is piped in

Closed this issue · 0 comments

I was trying to run sudo dmesg --color=always | moar and discovered it works when I have already run a sudo command (and entered my password) in the same shell, but if I haven't, it seems to go a bit crazy.

First when I enter this command I get this screen:

Then, hitting enter once or twice I eventually get a crash log (shown at the bottom of this report).

Trying the same thing, but piping to less -R instead (just using -R for the colour), this seems to work fine and the password prompt appears on an otherwise blank terminal screen at the very bottom, and then when entered it shows the file correctly.

I suspect the problem is something to do with how moar is handling the password prompt/need for a password before seeing the output?

I am running Arch and installed moar via the AUR with yay.

Crash report

Version: 1.23.6
LANG   : en_GB.UTF-8
TERM   : xterm-256color

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

panic: one-based line numbers must be at least 1, got 0 [recovered]
	panic: one-based line numbers must be at least 1, got 0 [recovered]
	panic: one-based line numbers must be at least 1, got 0

goroutine 1 [running]:
main.main.func1()
	github.com/walles/moar/moar.go:759 +0x155
panic({0x62c0bc721f00?, 0xc00043e720?})
	runtime/panic.go:770 +0x132
main.startPaging.func1()
	github.com/walles/moar/moar.go:810 +0xb0
panic({0x62c0bc721f00?, 0xc00043e720?})
	runtime/panic.go:770 +0x132
github.com/walles/moar/m/linenumbers.LineNumberFromOneBased(...)
	github.com/walles/moar/m/linenumbers/linenumber.go:27
github.com/walles/moar/m.(*PagerModeGotoLine).onKey(0xc000180000?, 0x56b5?)
	github.com/walles/moar/m/pagermode-go-to-line.go:40 +0x2ae
github.com/walles/moar/m.(*Pager).StartPaging(0xc000180000, {0x62c0bc75d538, 0xc0004b05a0}, 0xc0001f2bc0, 0xc000517f20)
	github.com/walles/moar/m/pager.go:394 +0x6e8
main.startPaging(0x0?, {0x62c0bc75d538?, 0xc0004b05a0?}, 0x1?, 0x1?)
	github.com/walles/moar/moar.go:821 +0x5f
main.main()
	github.com/walles/moar/moar.go:780 +0x291
Sorry, try again.
[sudo] password for joel: