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

Cannot pipe yes to zk init #172

Closed
j-hui opened this issue Feb 22, 2022 · 2 comments
Closed

Cannot pipe yes to zk init #172

j-hui opened this issue Feb 22, 2022 · 2 comments

Comments

@j-hui
Copy link

j-hui commented Feb 22, 2022

I'm used to piping yes to interactive programs for which I want to automatically hit <CR> for each prompted item. However, this does not work with zk:

$ yes '' | zk init
? Do you prefer [[WikiLinks]] over regular Markdown links? (y/N) panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6367aa]

goroutine 1 [running]:
github.com/AlecAivazis/survey/v2/terminal.(*RuneReader).ReadLineWithDefault.func2(...)
	github.com/AlecAivazis/survey/v2@v2.3.2/terminal/runereader.go:65
github.com/AlecAivazis/survey/v2/terminal.(*RuneReader).ReadLineWithDefault(0xc0000ea900, 0x0, 0x10e1e48, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4576cc, 0x50362b, ...)
	github.com/AlecAivazis/survey/v2@v2.3.2/terminal/runereader.go:321 +0xf0a
github.com/AlecAivazis/survey/v2/terminal.(*RuneReader).ReadLine(...)
	github.com/AlecAivazis/survey/v2@v2.3.2/terminal/runereader.go:37
github.com/AlecAivazis/survey/v2.(*Confirm).getBool(0xc0000c68f0, 0xb4f600, 0xc0002f1388, 0xae2800, 0x0, 0x0)
	github.com/AlecAivazis/survey/v2@v2.3.2/confirm.go:57 +0x191
github.com/AlecAivazis/survey/v2.(*Confirm).Prompt(0xc0000c68f0, 0xc0002f1388, 0xc000010010, 0xc35598, 0xc000010018, 0xc31c00)
	github.com/AlecAivazis/survey/v2@v2.3.2/confirm.go:136 +0x16d
github.com/AlecAivazis/survey/v2.Ask(0xc000725808, 0x2, 0x2, 0xa65f20, 0xc0001bfb60, 0x0, 0x0, 0x0, 0xa45100, 0x1a)
	github.com/AlecAivazis/survey/v2@v2.3.2/survey.go:308 +0x57b
github.com/mickael-menu/zk/internal/cli/cmd.startInitWizard(0xc0001c20c0, 0xaa12a0, 0xc0001bfb20)
	github.com/mickael-menu/zk/internal/cli/cmd/init.go:85 +0x231
github.com/mickael-menu/zk/internal/cli/cmd.newInitOpts(0xc000102c00, 0x4aac05, 0xadfaa0, 0xadfaa0)
	github.com/mickael-menu/zk/internal/cli/cmd/init.go:53 +0x51
github.com/mickael-menu/zk/internal/cli/cmd.(*Init).Run(0xf32f20, 0xc000102c00, 0x0, 0x0)
	github.com/mickael-menu/zk/internal/cli/cmd/init.go:20 +0x32
reflect.Value.call(0xa8d8a0, 0xf32f20, 0x213, 0xb2ab93, 0x4, 0xc000591758, 0x1, 0x1, 0x1, 0x0, ...)
	reflect/value.go:476 +0x8e7
reflect.Value.Call(0xa8d8a0, 0xf32f20, 0x213, 0xc000591758, 0x1, 0x1, 0x0, 0x1, 0xc000094d58)
	reflect/value.go:337 +0xb9
github.com/alecthomas/kong.callMethod(0xb2a3e0, 0x3, 0xaac0e0, 0xf32f20, 0x199, 0xa8d8a0, 0xf32f20, 0x213, 0xc0001c2030, 0xc0002c0110, ...)
	github.com/alecthomas/kong@v0.2.18-0.20210927063154-5c7b038540ab/callbacks.go:97 +0x4ba
github.com/alecthomas/kong.(*Context).RunNode(0xc0003b2480, 0xc0000e62a0, 0xc000725f68, 0x1, 0x1, 0xc000238fd8, 0xc00058def0)
	github.com/alecthomas/kong@v0.2.18-0.20210927063154-5c7b038540ab/context.go:731 +0x545
github.com/alecthomas/kong.(*Context).Run(0xc0003b2480, 0xc000725f68, 0x1, 0x1, 0xc0003b2480, 0x0)
	github.com/alecthomas/kong@v0.2.18-0.20210927063154-5c7b038540ab/context.go:747 +0x65
main.main()
	github.com/mickael-menu/zk/main.go:103 +0x3e5

I'm aware I can do zk init --no-input to accomplish what I intended to do in the first place, so this is not a big issue, but I wanted file this issue in case others run into it too, and in case this is a very easy fix.

@mickael-menu
Copy link
Member

It looks like an issue in the third-party library AlecAivazis/survey. Feel free to open an issue on its repo if you want. As it's not a common use case / issue for zk, I'll close this for now.

@j-hui
Copy link
Author

j-hui commented Feb 23, 2022

Got it, thanks! This seems to be related to AlecAivazis/survey#394

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

2 participants