Subject: [PATCH] guix: Only issue erase-current-line sequence for ttys.

From: Bruno Victal <[email-masked]>
Date: Wed, 8 Mar 2023 15:55:56 +0000

* guix/progress.scm (erase-current-line): Only issue erase-current-line sequence for ttys.
---

Avoids cluttering log lines with �[K when output is logged to a file.

 guix/progress.scm | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/guix/progress.scm b/guix/progress.scm
index 33cf6f4a1a..a1cdd25557 100644
--- a/guix/progress.scm
+++ b/guix/progress.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2015 Steve Sprang <[email-masked]>
 ;;; Copyright © 2017, 2018, 2019, 2020 Ludovic Courtès <[email-masked]>
 ;;; Copyright © 2018 Clément Lassieur <[email-masked]>
+;;; Copyright © 2023 Bruno Victal <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -209,9 +210,12 @@ (define* (progress-bar % #:optional (bar-width 20))
                    (string (progress-bar-style-stop bar-style)))))
 
 (define (erase-current-line port)
-  "Write an ANSI erase-current-line sequence to PORT to erase the whole line and
-move the cursor to the beginning of the line."
-  (display "\r\x1b[K" port))
+  "When @var{port} is interactive, write an ANSI erase-current-line sequence
+to erase the whole line and move the cursor to the beginning of the line,
+otherwise write a newline."
+  (if (isatty? port)
+      (display "\r\x1b[K" port)
+      (newline port)))
 
 (define* (display-download-progress file size
                                     #:key

base-commit: 85d4e8af5baf9b0a9cadf95d802674d0254433da
-- 
2.39.1