commit:     9da7a8c60083053a607af9642bd3ba80ecd112f9
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Thu May 22 20:09:27 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri May 30 07:37:30 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=9da7a8c6

90gcc-warnings: don't process gzip streams with sed

In the case that the log file is compressed, the routine that collects
the warnings ought to operate on the decompressed stream at large. Make
it so.

Fixes: b78da6155975faa519f93ec0bebe9830dd265c09
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/install-qa-check.d/90gcc-warnings | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/bin/install-qa-check.d/90gcc-warnings 
b/bin/install-qa-check.d/90gcc-warnings
index ead1243bb5..9ec16f1585 100644
--- a/bin/install-qa-check.d/90gcc-warnings
+++ b/bin/install-qa-check.d/90gcc-warnings
@@ -3,7 +3,7 @@
 # TODO: add -Wformat-security
 
 gcc_warn_check() {
-        local abort f grep_cmd joined_msgs reset_xtrace
+        local abort f joined_msgs reset_xtrace
         local -a msgs
 
        # Evaluate misc gcc warnings
@@ -151,13 +151,19 @@ gcc_warn_check() {
        printf -v joined_msgs '%s|' "${msgs[@]}"
        joined_msgs=${joined_msgs%|}
 
-       grep_cmd=grep
-       [[ ${PORTAGE_LOG_FILE} = *.gz ]] && grep_cmd=zgrep
-
        # Force C locale to work around slow multibyte locales, bug #160234
        # Force text mode as newer grep will treat non-ASCII (e.g. UTF-8) as
        # binary when we run in the C locale.
-       f=$(LC_ALL='C' sed -E -e $'s/\033\[[0-9;]*[A-Za-z]//g' < 
"${PORTAGE_LOG_FILE}" | LC_CTYPE=C LC_COLLATE=C "${grep_cmd}" -E -a 
"${joined_msgs}" | uniq)
+       f=$(
+               if [[ ${PORTAGE_LOG_FILE} == *.gz ]]; then
+                       gzip -cd -- "${PORTAGE_LOG_FILE}"
+               else
+                       cat -- "${PORTAGE_LOG_FILE}"
+               fi \
+               | LC_ALL=C sed -E -e $'s/\033\[[0-9;]*[A-Za-z]//g' \
+               | LC_CTYPE=C LC_COLLATE=C grep -E -a "${joined_msgs}" \
+               | uniq
+       )
        if [[ -n ${f} ]] ; then
                abort=1
 

Reply via email to