mirror of
https://github.com/go-task/task.git
synced 2025-06-15 00:15:10 +02:00
fix segmentation fault on nil slice element
This commit is contained in:
33
variables.go
33
variables.go
@ -90,34 +90,43 @@ func (e *Executor) compiledTask(call taskfile.Call, evaluateShVars bool) (*taskf
|
||||
}
|
||||
|
||||
if len(origTask.Cmds) > 0 {
|
||||
new.Cmds = make([]*taskfile.Cmd, len(origTask.Cmds))
|
||||
for i, cmd := range origTask.Cmds {
|
||||
new.Cmds[i] = &taskfile.Cmd{
|
||||
new.Cmds = make([]*taskfile.Cmd, 0, len(origTask.Cmds))
|
||||
for _, cmd := range origTask.Cmds {
|
||||
if cmd == nil {
|
||||
continue
|
||||
}
|
||||
new.Cmds = append(new.Cmds, &taskfile.Cmd{
|
||||
Task: r.Replace(cmd.Task),
|
||||
Silent: cmd.Silent,
|
||||
Cmd: r.Replace(cmd.Cmd),
|
||||
Vars: r.ReplaceVars(cmd.Vars),
|
||||
IgnoreError: cmd.IgnoreError,
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
if len(origTask.Deps) > 0 {
|
||||
new.Deps = make([]*taskfile.Dep, len(origTask.Deps))
|
||||
for i, dep := range origTask.Deps {
|
||||
new.Deps[i] = &taskfile.Dep{
|
||||
new.Deps = make([]*taskfile.Dep, 0, len(origTask.Deps))
|
||||
for _, dep := range origTask.Deps {
|
||||
if dep == nil {
|
||||
continue
|
||||
}
|
||||
new.Deps = append(new.Deps, &taskfile.Dep{
|
||||
Task: r.Replace(dep.Task),
|
||||
Vars: r.ReplaceVars(dep.Vars),
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if len(origTask.Preconditions) > 0 {
|
||||
new.Preconditions = make([]*taskfile.Precondition, len(origTask.Preconditions))
|
||||
for i, precond := range origTask.Preconditions {
|
||||
new.Preconditions[i] = &taskfile.Precondition{
|
||||
new.Preconditions = make([]*taskfile.Precondition, 0, len(origTask.Preconditions))
|
||||
for _, precond := range origTask.Preconditions {
|
||||
if precond == nil {
|
||||
continue
|
||||
}
|
||||
new.Preconditions = append(new.Preconditions, &taskfile.Precondition{
|
||||
Sh: r.Replace(precond.Sh),
|
||||
Msg: r.Replace(precond.Msg),
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user