commit:     3498e0f1c1fe6c7f23707d0e56462fbc8dfb487d
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Mon Jun  9 08:53:27 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jun 11 03:26:15 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=3498e0f1

ecompress: always treat PORTAGE_COMPRESS as a discrete command name

Recently, the guess_suffix() function was made to use the read builtin
to safely split some of the words contained by the environment variables
'PORTAGE_COMPRESS' and 'PORTAGE_COMPRESS_FLAGS', like so.

  read -rd '' -a cmd <<<"${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS}"

However, to split the value of the former variable is improper. The
status quo is that its value always be treated as the command name,
meaning that it should not be split. Address this by splitting only the
value of 'PORTAGE_COMPRESS_FLAGS'.

Note that I am not designating this as a fix for my prior commit because
the prior code was also incorrect in this respect. It was only upon
studying ecompress-file - which properly quotes the expansion of
'PORTAGE_COMPRESS' - that this long-standing discrepancy became clear.

See-also: a722142b8676a46c432e77133ec97d802edd1845
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/ecompress | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/bin/ecompress b/bin/ecompress
index 1169255674..2dc663bf44 100755
--- a/bin/ecompress
+++ b/bin/ecompress
@@ -118,7 +118,7 @@ do_queue() {
 
 guess_suffix() {
        local IFS f i tmpdir
-       local -a cmd
+       local -a args
 
        trap 'rm -rf -- "${tmpdir}"' RETURN
 
@@ -133,8 +133,8 @@ guess_suffix() {
                printf '%s ' "${i}" || ! break
        done > compressme || return
 
-       read -rd '' -a cmd <<<"${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS}"
-       "${cmd[@]}" compressme > /dev/null || return
+       read -rd '' -a args <<<"${PORTAGE_COMPRESS_FLAGS}"
+       "${PORTAGE_COMPRESS}" "${args[@]}" compressme > /dev/null || return
 
        # If PORTAGE_COMPRESS_FLAGS contains -k then we need to avoid
        # having our glob match the uncompressed file here.

Reply via email to