From 7c12b1ee83b7b6f9d515c1451bd100e1fe10f3ba Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Sun, 8 Feb 2026 14:45:53 +0100 Subject: [PATCH] Disable progress bar when output is piped Modify CLIProgressBar function to check if stdout is a named pipe and disable the progress bar accordingly. This prevents the progress bar from being displayed when the output is redirected or piped to another command. --- pkg/obitools/obiconvert/options.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/obitools/obiconvert/options.go b/pkg/obitools/obiconvert/options.go index 3776bdf..4c5f0b2 100644 --- a/pkg/obitools/obiconvert/options.go +++ b/pkg/obitools/obiconvert/options.go @@ -224,13 +224,16 @@ func CLIAnalyzeOnly() int { func CLIProgressBar() bool { // If the output is not a terminal, then we do not display the progress bar - o, _ := os.Stderr.Stat() - onTerminal := (o.Mode() & os.ModeCharDevice) == os.ModeCharDevice + oe, _ := os.Stderr.Stat() + onTerminal := (oe.Mode() & os.ModeCharDevice) == os.ModeCharDevice if !onTerminal { log.Info("Stderr is redirected, progress bar disabled") } - return onTerminal && !__no_progress_bar__ + oo, _ := os.Stdout.Stat() + toPipe := (oo.Mode() & os.ModeNamedPipe) == os.ModeNamedPipe + + return onTerminal && !toPipe && !__no_progress_bar__ } func CLIOutPutFileName() string {