>From 20642ae4aa3847403d3462e74ace4c00ca3240b3 Mon Sep 17 00:00:00 2001 From: Michael Shigorin Date: Wed, 28 Apr 2021 15:06:57 +0300 Subject: [PATCH 3/3] reports.mk: use process substitution to dedup The first half of both pipes was clearly a copy-pasted initial logfile processing; the file can be of considerable size (e.g. several megabytes) so it might be slightly more efficient and cool (but a bit more arcane) to use bash(1)'s process substitution along with good ol' tee(1) like this: $ echo -e '1\n2\n3' |tee /dev/stderr 2> >(grep 2 >STDERR) |grep 1 >STDOUT $ head STD* ==> STDERR <== 2 ==> STDOUT <== 1 --- reports.mk | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/reports.mk b/reports.mk index 7b81e785a..247c722b5 100644 --- a/reports.mk +++ b/reports.mk @@ -78,11 +78,10 @@ reports/contents: reports/prep esac reports/packages: reports/prep - @grep -E 'chroot/.in/[^/]*.rpm' < $(BUILDLOG) | \ - cut -d' ' -f 1 | tr -d "'"'`' | sed 's,^.*/,,' | \ - sort -u > "$(REPORTDIR)/list-rpms.txt" @grep -E 'chroot/.in/[^/]*.rpm' < $(BUILDLOG) | \ cut -d' ' -f 1 | tr -d "'"'`' | \ + tee /dev/stderr 2> >(sed 's,^.*/,,' | \ + sort -u > "$(REPORTDIR)/list-rpms.txt") | \ xargs rpm -qp --queryformat '%{sourcerpm}\n' | \ sort -u > "$(REPORTDIR)/list-srpms.txt" -- 2.25.4