Checkupdates: Preserve pacman colors when printing the list of pending updates
The colors for the listing of pending updates are inherited from the "Color" option in /etc/pacman.conf
(since it uses pacman -Qu
to generate the list).
However, since the list is put into an array via a mapfile the colors are not preserved. Indeed, the "Color" option in /etc/pacman.conf
correspond to the --color auto
pacman flag which prints colors only when outputting onto in a TTY (which a mapfile/array is not
This commit makes checkupdates
forcing the use of --color always
during the pacman -Qu
command in the mapfile to generate the list of pending updates with colors for users that have the "Color" option enabled in the pacman.conf
.
Merge request reports
Activity
mentioned in issue #117 (closed)
Here's a PKGUILD to build a pacman-contrib package including this change for testing purposes:
# Maintainer: Johannes Löthberg <johannes@kyriasis.com> # Maintainer: Daniel M. Capella <polyzen@archlinux.org> pkgname=pacman-contrib pkgver=1.10.1 pkgrel=1 pkgdesc='Contributed scripts and tools for pacman systems' arch=('x86_64') url=https://gitlab.archlinux.org/antiz/pacman-contrib license=('GPL') depends=('fakeroot' 'pacman' 'perl') makedepends=('asciidoc' 'git') optdepends=('diffutils: for pacdiff' 'findutils: for pacdiff --find' 'mlocate: for pacdiff --locate' 'sudo: privilege elevation for several scripts' 'vim: default merge program for pacdiff') source=("git+$url.git#branch=checkupdates_colors") b2sums=('SKIP') validpgpkeys=('04DC3FB1445FECA813C27EFAEA4F7B321A906AD9') # Daniel M. Capella <polyzen@archlinux.org> # '5134EF9EAF65F95B6BB1608E50FB9B273A9D0BB5') # Johannes Löthberg <johannes@kyriasis.com> prepare() { cd $pkgname ./autogen.sh } build() { cd $pkgname ./configure \ --prefix=/usr \ --sysconfdir=/etc \ --localstatedir=/var make } check() { cd $pkgname make check } package() { cd $pkgname make DESTDIR="$pkgdir" install } # vim:set ts=2 sw=2 et:
added 1 commit
- 9b1b52c9 - Use --color always as the mapfile isn't a TTY
added 1 commit
- f98efcc7 - Use `--color always` during the `pacman -Qu` command in the mapfile to...
Eventually... If the aim for pacman-contrib is to stay close to pacman's way of handling such option, then maybe we should consider this indeed.
Although,checkupdates
isn't the only script with the--nocolor
option so, if anything, it should be done globally in a separate MR IMO.PS: Thanks for the fixup commit. I wasn't sure if we wanted to link the color option from checkupdates to this (since it's actually another package's option) but I guess it makes sense that way!
Edited by Robin Candau
mentioned in commit 5472d4f7