[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#62056] [PATCH] guix: Only issue erase-current-line sequence for tty
From: |
Ludovic Courtès |
Subject: |
[bug#62056] [PATCH] guix: Only issue erase-current-line sequence for ttys. |
Date: |
Thu, 16 Mar 2023 22:30:06 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
Hi,
Bruno Victal <mirai@makinata.eu> skribis:
> * 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.
+1!
> (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)))
We should avoid calling ‘isatty?’ every time, it’s too costly, which is
why there’s also ‘isatty?*’ somewhere that memoizes things.
However, it seems up to the caller to check that before calling
‘erase-current-line’. That seems to be the case within progress.scm and
in (guix status).
Could you see which use of ‘erase-current-line’ is causing problems?
TIA,
Ludo’.