From 52765e0350629bd22aea8eead630c9efe09ec5f9 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 15 Sep 2026 14:01:07 +0200 Subject: fix: close the review nits in the write path, query path and tests Remove the temp file on every writeJSON failure path, not just the write and close ones. A failed rename left the temp behind with no cleanup. Surface the list path's unmarshal error instead of printing null with exit 0, and make a non-positive history limit print an empty array rather than falling through to the whole ring. Assert the evicted item actually lands in the history ring, so the "files to history" half of eviction is covered rather than just its signal. Add the missing README License section beside the GPLv2 text and headers. --- cmd/notifyctl/main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'cmd/notifyctl') diff --git a/cmd/notifyctl/main.go b/cmd/notifyctl/main.go index ca1db86..e0875e7 100644 --- a/cmd/notifyctl/main.go +++ b/cmd/notifyctl/main.go @@ -52,6 +52,10 @@ func main() { } limit = n } + if limit < 1 { + fmt.Println("[]") + return + } printFile("history.json", limit) case "close": need(3) @@ -106,7 +110,10 @@ func printFile(name string, limit int) { return } var pretty any - json.Unmarshal(data, &pretty) + if err := json.Unmarshal(data, &pretty); err != nil { + fmt.Fprintf(os.Stderr, "notifyctl: %v\n", err) + os.Exit(1) + } out, _ := json.MarshalIndent(pretty, "", " ") fmt.Println(string(out)) } -- cgit v1.2.3