guix-patches
[Top][All Lists]
Advanced

[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: Bruno Victal
Subject: [bug#62056] [PATCH] guix: Only issue erase-current-line sequence for ttys.
Date: Sat, 18 Mar 2023 11:27:12 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0

Hi Ludo’,

On 2023-03-16 21:30, Ludovic Courtès wrote:
> Bruno Victal <mirai@makinata.eu> skribis:
>>  (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).

guix/status.scm:471 defines a erase-current-line* which calls isatty?*.
Does this mean that erase-current-line has to be “wrapped” every time
we want it to have tty awareness?

If that's not the case, perhaps we could change the signature of 
erase-current-line to:
(define* (erase-current-line port #:optional tty?)


> Could you see which use of ‘erase-current-line’ is causing problems?

guix/scripts/substitute.scm:318


Cheers,
Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]