all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Bruno Victal <mirai@makinata.eu>
To: 62056@debbugs.gnu.org
Cc: Bruno Victal <mirai@makinata.eu>
Subject: [bug#62056] [PATCH] guix: Only issue erase-current-line sequence for ttys.
Date: Wed,  8 Mar 2023 15:55:56 +0000	[thread overview]
Message-ID: <6a78ee837fe579d6b1beaeda54beddba3c05fd2e.1678290800.git.mirai@makinata.eu> (raw)

* 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 <scs@stevesprang.com>
 ;;; Copyright © 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
+;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu>
 ;;;
 ;;; 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





             reply	other threads:[~2023-03-08 15:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-08 15:55 Bruno Victal [this message]
2023-03-16 21:30 ` [bug#62056] [PATCH] guix: Only issue erase-current-line sequence for ttys Ludovic Courtès
2023-03-18 11:27   ` Bruno Victal
2023-04-18 20:02     ` Ludovic Courtès
2023-05-28  9:54       ` Bruno Victal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6a78ee837fe579d6b1beaeda54beddba3c05fd2e.1678290800.git.mirai@makinata.eu \
    --to=mirai@makinata.eu \
    --cc=62056@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.