Repository navigation
Closed
Description
I am trying to use an interactive script for setting dynamic variables. If read is used directly in the Taskfile, this results in a panic (see below).
If a script file containing a read statement is used instead, this also fails, but without panic (task: ... failed: exit status 1). However the culprit also seems to be the read statement, script just runs until there.
Is interactive input supported for setting dynamic variables? I was expecting so, since it does work for commands, but maybe that is just a false assumption.
- Task version: 3.3.0
- Operating System: macOS 11.2.
Taskfile
version: '3'
tasks:
test1:
cmds:
- echo {{ .dynval }}
vars:
dynval:
sh: read -r; echo $REPLYResult
$ task test1
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x1228644]
goroutine 1 [running]:
mvdan.cc/sh/v3/interp.(*Runner).readLine(0xc0001ae200, 0x1, 0x1, 0x0, 0xffffffffffffffff, 0x16718d0, 0x290)
/home/runner/go/pkg/mod/mvdan.cc/sh/v3@v3.2.4/interp/builtin.go:676 +0x84
mvdan.cc/sh/v3/interp.(*Runner).builtinCode(0xc0001ae200, 0x13b4720, 0xc0000a0000, 0x1000100000000, 0xc0001de030, 0x4, 0xc00019a410, 0x1, 0x1, 0x0)
/home/runner/go/pkg/mod/mvdan.cc/sh/v3@v3.2.4/interp/builtin.go:490 +0xbaa
mvdan.cc/sh/v3/interp.(*Runner).call(0xc0001ae200, 0x13b4720, 0xc0000a0000, 0x1000100000000, 0xc00019a3f0, 0x3, 0x3)
/home/runner/go/pkg/mod/mvdan.cc/sh/v3@v3.2.4/interp/runner.go:746 +0x373
mvdan.cc/sh/v3/interp.(*Runner).cmd(0xc0001ae200, 0x13b4720, 0xc0000a0000, 0x13b31e0, 0xc0001ee000)
/home/runner/go/pkg/mod/mvdan.cc/sh/v3@v3.2.4/interp/runner.go:345 +0x14c8
mvdan.cc/sh/v3/interp.(*Runner).stmtSync(0xc0001ae200, 0x13b4720, 0xc0000a0000, 0xc0001b7800)
/home/runner/go/pkg/mod/mvdan.cc/sh/v3@v3.2.4/interp/runner.go:285 +0x312
mvdan.cc/sh/v3/interp.(*Runner).stmt(0xc0001ae200, 0x13b4720, 0xc0000a0000, 0xc0001b7800)
/home/runner/go/pkg/mod/mvdan.cc/sh/v3@v3.2.4/interp/runner.go:266 +0x1e7
mvdan.cc/sh/v3/interp.(*Runner).stmts(0xc0001ae200, 0x13b4720, 0xc0000a0000, 0xc0001f0000, 0x2, 0x4)
/home/runner/go/pkg/mod/mvdan.cc/sh/v3@v3.2.4/interp/runner.go:603 +0x57
mvdan.cc/sh/v3/interp.(*Runner).Run(0xc0001ae200, 0x13b4720, 0xc0000a0000, 0x13b0160, 0xc00018c140, 0x0, 0xc00019a360)
/home/runner/go/pkg/mod/mvdan.cc/sh/v3@v3.2.4/interp/api.go:504 +0x2ea
github.com/go-task/task/v3/internal/execext.RunCommand(0x13b4720, 0xc0000a0000, 0xc000129370, 0x18, 0x1583520)
/home/runner/work/task/task/internal/execext/exec.go:58 +0x352
github.com/go-task/task/v3/internal/compiler/v3.(*CompilerV3).HandleDynamicVar(0xc0000b2580, 0x0, 0x0, 0x0, 0x0, 0xc0001e2020, 0x18, 0x0, 0x0, 0x0, ...)
/home/runner/work/task/task/internal/compiler/v3/compiler_v3.go:127 +0x26f
github.com/go-task/task/v3/internal/compiler/v3.(*CompilerV3).getVariables.func1.1(0xc0000a0a50, 0x6, 0x0, 0x0, 0x0, 0x0, 0xc0001e2020, 0x18, 0x0, 0x0, ...)
/home/runner/work/task/task/internal/compiler/v3/compiler_v3.go:61 +0x245
github.com/go-task/task/v3/taskfile.(*Vars).Range(0xc0000aa6e0, 0xc00019a0c0, 0xc00019a0c0, 0x0)
/home/runner/work/task/task/taskfile/var.go:68 +0x142
github.com/go-task/task/v3/internal/compiler/v3.(*CompilerV3).getVariables(0xc0000b2580, 0xc0000c4d80, 0x7ffeefbffacd, 0x5, 0x0, 0xc00009d501, 0xc0000e4100, 0xc00009d5f0, 0x1)
/home/runner/work/task/task/internal/compiler/v3/compiler_v3.go:93 +0x2c5
github.com/go-task/task/v3/internal/compiler/v3.(*CompilerV3).GetVariables(0xc0000b2580, 0xc0000c4d80, 0x7ffeefbffacd, 0x5, 0x0, 0x1, 0x1, 0xc000129c08)
/home/runner/work/task/task/internal/compiler/v3/compiler_v3.go:33 +0x58
github.com/go-task/task/v3.(*Executor).compiledTask(0xc0000fe000, 0x7ffeefbffacd, 0x5, 0x0, 0x100d401, 0xc00019a030, 0x30, 0x30)
/home/runner/work/task/task/variables.go:33 +0xe4
github.com/go-task/task/v3.(*Executor).CompiledTask(...)
/home/runner/work/task/task/variables.go:16
github.com/go-task/task/v3.(*Executor).RunTask(0xc0000fe000, 0x13b46e0, 0xc00018c040, 0x7ffeefbffacd, 0x5, 0x0, 0x0, 0x0)
/home/runner/work/task/task/task.go:261 +0x8c
github.com/go-task/task/v3.(*Executor).Run(0xc0000fe000, 0x13b46e0, 0xc00018c000, 0xc0000aa7a0, 0x1, 0x1, 0x0, 0x0)
/home/runner/work/task/task/task.go:96 +0x39a
main.main()
/home/runner/work/task/task/cmd/task/task.go:187 +0xe85
Reacted by Shiv Krishna Jaiswal
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
No fields configured for bug.
Activity
rupkoe commentedon Apr 9, 2021
Seems this could be fixed by simply adding
Stdin: os.Stdin,here:task/internal/compiler/v3/compiler_v3.go
Line 124 in fe917af
This would also enable some form of interactive prompts without adding an extra feature to Task (like asked for in #236):
Could this be a viable solution?
andreynering commentedon Jul 11, 2021
Hi @rupkoe,
Unfortunately
readon variables isn't supported.This
panicwas reported before at #420 and was fixed already. I tried your example and couldn't reproduce on the last release.If you somehow can still reproduce on the most recent release, please let me know.