Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
b4shful opened this issue Mar 5, 2024 · 0 comments

Comments

@b4shful
Copy link

b4shful commented Mar 5, 2024

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: 
walles added a commit that referenced this issue Mar 13, 2024
When entering `0` as the go-to-line number.

Reported here:
#199

Note that this just prevents the crash, but it doesn't make sudo work
any better so the ticket should still be open.
@walles walles closed this as completed in b82895c Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant