aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorBryan McNulty <bryanmcnulty@protonmail.com>2025-04-25 17:13:55 -0500
committerBryan McNulty <bryanmcnulty@protonmail.com>2025-04-25 17:13:55 -0500
commit3c6d9d22445a274aad26005face44f171ba4465d (patch)
tree45893683d9525ce2bf1b2c50222b4fbf895b5382 /cmd
parent865b523bdd4b006661ef8fbf76d24e4b7ad1cf8e (diff)
downloadgoexec-3c6d9d22445a274aad26005face44f171ba4465d.tar.gz
goexec-3c6d9d22445a274aad26005face44f171ba4465d.zip
Avoid panic when closing log file
Diffstat (limited to 'cmd')
-rw-r--r--cmd/root.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/cmd/root.go b/cmd/root.go
index 33b0116..d00ea2a 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -151,11 +151,15 @@ Authors: FalconOps LLC (@FalconOpsLLC),
},
PersistentPostRun: func(cmd *cobra.Command, args []string) {
- if err := logFile.Close(); err != nil {
- // ...
+ if logFile != nil {
+ if err := logFile.Close(); err != nil {
+ // ...
+ }
}
- if err := exec.Input.StageFile.Close(); err != nil {
- // ...
+ if exec.Input != nil && exec.Input.StageFile != nil {
+ if err := exec.Input.StageFile.Close(); err != nil {
+ // ...
+ }
}
},
}