Control: severity -1 normal

(I hope at the end its understandable why I downgrade the severity)

Hi,

Am Sat, Sep 28, 2024 at 10:11:24PM GMT, schrieb Andres Salomon:
> Here's the log from my terminal:
[…]
> dilinger@debian:~$ sudo apt autoremove --purge libgtk-3-common
> Building dependency tree... 0%

This line is suspicious as it should have disappeared – like the rest of
the progress reporting. That it hasn't indicates that your terminal
acted on more input than expected – as in you pressed ENTER for a bit
too long firing of the apt command generating a new line.

Harmless, right … ?


> Summary:
>   Upgrading: 0, Installing: 1, Removing: 448, Not Upgrading: 0
>   Download size: 79.7 kB
>   Freed space: 1,714 MB
> 
> Get:1 http://deb.debian.org/debian trixie/main amd64 pinentry-curses amd64 
> 1.2.1-4+b1 [79.7 kB]

In fact, I can easily reproduce this behaviour with any apt command
usually asking a question if I keep holding ENTER for a bit longer…
which is not too unsurprising as pressing ENTER on the confirmation
prompt is considered a valid confirmation. I wonder a bit how the
line ends up disappearing through.

A command which defaults to 'No' on enter like the very wrong:
 apt upgrade -o Dir::Usr=/sys/firmware/efi/efivars
(to force a more space needed warning at least on my system)
has the output appearing…


A wait, I get why: "Continue?" (and the other prompts) are not
terminated by a newline, so if you press enter at the intended time
the newline is added and the download happens on a fresh line (or in the
case of the default No we generate additional output producing a new
line).

If you pressed enter too early the newline will have been entered
somewhere in the previous output already (remember the 0% ?),
so the download progress line happens to override the silently
confirmed prompt.


That is a fun one! And a bit surprising nobody else stumbled over this
as this can be reproduced with any and all versions of apt (and massive
amounts of other terminal software). In our case it seems reasonable to
"just" ignore any input given before we show the prompt. Except that
someone might be doing e.g. "echo yeah | apt …" and that would break,
so better only if input is a tty.

Now, that "breaks" a user on slow machines that take a while to generate
the listings that just hits confirm after the REMOVE section is done (in
old order – now we know why it was given first 😉), so they have to wait
now for the prompt, but… oh well, --no-remove --assume-yes could work
for this straw man user instead I guess (https://xkcd.com/1172/).

MR on salsa: https://salsa.debian.org/apt-team/apt/-/merge_requests/375


Best regards

David Kalnischkies

Attachment: signature.asc
Description: PGP signature

Reply via email to