1
0
mirror of https://github.com/go-task/task.git synced 2025-03-17 21:08:01 +02:00

fix: non-evaluated nil values should be converted to empty strings to avoid empty interface errors in the templater

This commit is contained in:
Pete Davison 2023-12-17 02:44:03 +00:00
parent cb195da72f
commit 43a2979e77

View File

@ -71,6 +71,12 @@ func (c *CompilerV3) getVariables(t *taskfile.Task, call *taskfile.Call, evaluat
if err := tr.Err(); err != nil {
return err
}
// If the variable should not be evaluated, but is nil, set it to an empty string
// This stops empty interface errors when using the templater to replace values later
if !evaluateShVars && newVar.Value == nil {
result.Set(k, taskfile.Var{Value: ""})
return nil
}
// If the variable is not dynamic, we can set it and return
if !evaluateShVars || newVar.Value != nil || newVar.Sh == "" {
result.Set(k, taskfile.Var{Value: newVar.Value})