From 831e31d48342cc4f8523c74ece6611471c53d655 Mon Sep 17 00:00:00 2001 From: matthias314 <56549971+matthias314@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:21:29 -0500 Subject: [PATCH] avoid creating `nil` callback for `JobSpawn` (#3554) --- internal/shell/job.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/shell/job.go b/internal/shell/job.go index 6e1f4b18..766b9516 100644 --- a/internal/shell/job.go +++ b/internal/shell/job.go @@ -78,8 +78,10 @@ func JobSpawn(cmdName string, cmdArgs []string, onStdout, onStderr, onExit func( go func() { // Run the process in the background and create the onExit callback proc.Run() - jobFunc := JobFunction{onExit, outbuf.String(), userargs} - Jobs <- jobFunc + if onExit != nil { + jobFunc := JobFunction{onExit, outbuf.String(), userargs} + Jobs <- jobFunc + } }() return &Job{proc, stdin}