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

fix: variable propagation (#1437)

This commit is contained in:
Pete Davison 2023-12-21 10:04:45 -06:00 committed by GitHub
parent 21ceb05080
commit 39a4b4d413
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,17 +68,23 @@ func (c *CompilerV3) getVariables(t *taskfile.Task, call *taskfile.Call, evaluat
}
newVar.Sh = tr.Replace(v.Sh)
newVar.Dir = v.Dir
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 should not be evaluated and it is set, we can set it and return
if !evaluateShVars {
result.Set(k, taskfile.Var{Value: newVar.Value})
return nil
}
// Now we can check for errors since we've handled all the cases when we don't want to evaluate
if err := tr.Err(); err != nil {
return err
}
// If the variable is not dynamic, we can set it and return
if !evaluateShVars || newVar.Value != nil || newVar.Sh == "" {
if newVar.Value != nil || newVar.Sh == "" {
result.Set(k, taskfile.Var{Value: newVar.Value})
return nil
}