Hi,
I have tested the behaviour on Debian 12 with unmodified apt 2.6.1 and
emacs 28.2.
The problem still exists.
The problem most probably is NOT related to dumb $TERM used inside of
emacs' shell because:
1. with non-dumb $TERM in emacs' shell the problem still occurs
I used the following steps to configure non-dumb $TERM after running
shell in emacs (M-x shell):
export TERM={linux|xterm-256color}
tput init
echo $TERM
After the three commands I ran apt to observe the progress bar:
apt {install|remove} libxml2-dev
2. with dumb $TERM in regular shell session (outside of emacs) I
experienced no problems with progress bar while running "apt
{install|remove} <package>".
What's interesting is the fact that emacs itself doesn't play well with
dumb $TERM. This is what is being printed in plain shell session when I
attempt to start emacs:
root@debian:~# emacs
emacs: Terminal type "dumb" is not powerful enough to run Emacs.
It lacks the ability to position the cursor.
[...]
Another interesting thing is the difference between output of "stty -a"
for plain shell and for emacs shell when $TERM is set to dumb, but I
won't bore you with details.
It looks like the problem with progress bars of different programs ran
inside of emacs is known to many people:
npm:
https://stackoverflow.com/questions/21785955/messed-up-progress-bars-when-installing-npm-packages-inside-ansi-term
yarn:
https://github.com/yarnpkg/yarn/issues/4927
pacman:
https://bbs.archlinux.org/viewtopic.php?id=121432
https://gitlab.archlinux.org/pacman/pacman/-/commit/330951200c8a0bb90937e0578510a41220154726
apt:
https://askubuntu.com/questions/956712/prevent-extraneous-formatting-of-apt-output
https://oremacs.com/2019/03/24/shell-apt/
So as a happy user of emacs myself I have to ask if this is a problem
with apt or a problem with emacs.
The last two links propose the following two workarounds:
1. Configure apt to use no fancy progress bar, either in config file or
like this:
apt -o Dpkg::Progress-Fancy=0 action args...
2. Use "apt-get" instead of "apt". IIUC, apt-get internally sets
Progress-Fancy to false internally.
I'm attaching a "kamil_progress_bar.txt" file that shows how the problem
with progress bar looks like in my case. Notice the messages from
debconf.
Kamil
root@debian:~# apt install libxml2-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
libxml2-dev
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/782 kB of archives.
After this operation, 3,358 kB of additional disk space will be used.
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell
buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
^[7^[8Selecting previously unselected package libxml2-dev:amd64.
(Reading database ... 86782 files and directories currently installed.)
Preparing to unpack .../libxml2-dev_2.9.14+dfsg-1.3~deb12u1_amd64.deb ...
^[7Progress: [ 0%]
[.......................................................................................................................................................................................................................]\
^[8^[7Progress: [ 20%]
[###########################################.........................................................................................................................................................................\
...] ^[8Unpacking libxml2-dev:amd64 (2.9.14+dfsg-1.3~deb12u1) ...
^[7Progress: [ 40%]
[######################################################################################.................................................................................................................................]\
^[8Setting up libxml2-dev:amd64 (2.9.14+dfsg-1.3~deb12u1) ...
^[7Progress: [ 60%]
[#################################################################################################################################......................................................................................]\
^[8^[7Progress: [ 80%]
[############################################################################################################################################################################........................................\
...] ^[8Processing triggers for man-db (2.11.2-2) ...
^[7^[8root@debian:~#
root@debian:~#