summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Lim <50560759+joelim-work@users.noreply.github.com>2024-11-17 23:10:20 +1100
committerGitHub <noreply@github.com>2024-11-17 23:10:20 +1100
commit68a29c92848397e642e060a83f8a1bd7bd979af2 (patch)
tree22e1391e76b8066acb725dce7d96f0005dc64d45
parentf0dddccb04f9e2f99146a6832ee7798a51cd6256 (diff)
Prevent infinite loop when using `on-quit` (#1856)HEADmaster
-rw-r--r--app.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/app.go b/app.go
index 45e0dbd..8fd2066 100644
--- a/app.go
+++ b/app.go
@@ -35,6 +35,7 @@ type app struct {
menuCompInd int
selectionOut []string
watch *watch
+ quitting bool
}
func newApp(ui *ui, nav *nav) *app {
@@ -66,6 +67,14 @@ func newApp(ui *ui, nav *nav) *app {
}
func (app *app) quit() {
+ // Using synchronous shell commands for `on-quit` can cause this to be
+ // called again, so a guard variable is introduced here to prevent an
+ // infinite loop.
+ if app.quitting {
+ return
+ }
+ app.quitting = true
+
onQuit(app)
if gOpts.history {