Prevent extraneous formatting of apt output
When using apt
from "dumb" terminal (this is a code word for Emacs), it produces many lines of garbage output (it probably tries to display progress, but it doesn't work on this kind of terminal).
The same happens if I try to save this information to a file, which blows up the logs contributing no useful information.
Thus, is there a way to prevent apt
from producing garbled output?
I've seen the SO question asking for the opposite, and I think that this behavior is new. So, if the version is important, it is: apt 1.4.6 (amd64)
For the use in scripts, dumb terminals etc. there is apt-get
, see man apt
:
apt
provides a high-level commandline interface for the package management system. It is intended as an end user interface and enables some options better suited for interactive usage by default compared to more specialized APT tools likeapt-get
(8) andapt-cache
(8).SCRIPT USAGE AND DIFFERENCES FROM OTHER APT TOOLS
The
apt
(8) commandline is designed as an end-user tool and it may change behavior between versions. While it tries not to break backward compatibility this is not guaranteed either if a change seems beneficial for interactive use.All features of
apt
(8) are available in dedicated APT tools likeapt-get
(8) andapt-cache
(8) as well.apt
(8) just changes the default value of some options (seeapt.conf
(5) and specifically the Binary scope). So you should prefer using these commands (potentially with some additional options enabled) in your scripts as they keep backward compatibility as much as possible.
There are more differences between apt
and apt-get
than the fancy progress bar, so you might want to turn that off while keeping all the other differences:
sudo apt -o Dpkg::Progress-Fancy=0 action args...
Some sources show Dpkg::Progress-Fancy="0"
, which is fine but equivalent to Dpkg::Progress-Fancy=0
since shells don't expand 0
anyway and the quotes are simply removed.
You probably don't want to change this setting globally because when you run apt
outside of Emacs you will likely want the fancy progress bar. However, you could make a shorter command that achieves the same goal, such as with an eshell alias.