From 4948ad41765b03edf2414b4ed223be67d0d37a65 Mon Sep 17 00:00:00 2001 From: Jacob Bandes-Storch Date: Thu, 12 Dec 2024 12:55:21 -0800 Subject: [PATCH] mcap recover: print status message to stderr instead of stdout (#1289) ### Changelog Fixed a bug in `mcap recover` which would produce an invalid file when redirecting stdout to a file. ### Docs None ### Description Status message now goes to stderr instead of stdout. Also fixed another nearby line which looked wrong, it was using Fprintln with `%w` but Fprintln doesn't accept format strings. https://pkg.go.dev/fmt#Fprintln --- go/cli/mcap/cmd/filter.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/go/cli/mcap/cmd/filter.go b/go/cli/mcap/cmd/filter.go index f6dff395f..2ed4d0999 100644 --- a/go/cli/mcap/cmd/filter.go +++ b/go/cli/mcap/cmd/filter.go @@ -257,11 +257,12 @@ func filter( defer func() { err := mcapWriter.Close() if err != nil { - fmt.Fprintln(os.Stderr, "failed to close mcap writer: %w", err) + fmt.Fprintf(os.Stderr, "failed to close mcap writer: %v\n", err) return } if opts.recover { - fmt.Printf( + fmt.Fprintf( + os.Stderr, "Recovered %d messages, %d attachments, and %d metadata records.\n", numMessages, numAttachments,