git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Print progress message to stderr, not stdout

From
Karl Hasselström <kha@treskal.com>
Date
Nov 11, 2006, 12:16 UTC
Message-ID
<20061111121625.8988.45195.stgit@localhost>

Printing progress messages to stdout causes them to get mixed up with the actual output of the program. Using stderr is much better, since the user can then redirect the two components separately.

Signed-off-by: Karl Hasselström <kha@treskal.com>
---

I noticed this when creating a patch with "stg export -s" for the import regression test.

 stgit/git.py |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/stgit/git.py b/stgit/git.py
index 2a6ae91..8d88769 100644
--- a/stgit/git.py
+++ b/stgit/git.py
@@ -186,8 +186,8 @@ def __tree_status(files = None, tree_id
     """Returns a list of pairs - [status, filename]
     """
     if verbose:
-        print 'Checking for changes in the working directory...',
-        sys.stdout.flush()
+        sys.stderr.write('Checking for changes in the working directory...')
+        sys.stderr.flush()
 
     refresh_index()
 
@@ -226,7 +226,7 @@ def __tree_status(files = None, tree_id
             cache_files.append(fs)
 
     if verbose:
-        print 'done'
+        print >> sys.stderr, 'done'
 
     return cache_files
Next: Marco Costalba
Message 1 of 10 in “Print progress message to stderr, not stdout”
  1. Print progress message to stderr, not stdoutKarl Hasselström, Nov 11, 2006
  2. Marco CostalbaDec 2, 2006
  3. Catalin MarinasDec 4, 2006
  4. Karl HasselströmDec 4, 2006
  5. Marco CostalbaDec 4, 2006
  6. Catalin MarinasDec 4, 2006
  7. Marco CostalbaDec 5, 2006
  8. Johannes SchindelinDec 5, 2006
  9. Karl HasselströmDec 5, 2006
  10. Catalin MarinasDec 5, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.