commit:     42890cc79d58b0aaebb025e0bdcc910e54cd738c
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sat Jan 24 23:17:21 2026 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jan 25 01:50:45 2026 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=42890cc7

phase-helpers.sh: unpack(): consider only non-empty suffixes as keys

Presently, the unpack() function tries to discern the suffix of each
operand before determining whether said suffix exists as a key of the
'suffix_by' array. Now, it is expected that files bearing no suffix
shall sometimes be encountered, in which case the value of the 'suffix'
variable shall remain as the null string. However, the key existence
check will still occur, resulting in the following error:

phase-helpers.sh: line 429: suffix_by: bad array subscript

Despite this, the function proceeds to act as it should by refraining
from attempting to unpack the file in question.

Address this issue by ensuring that the value of 'suffix' is non-empty
before subjecting it to test -v.

Closes: https://bugs.gentoo.org/969217
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/phase-helpers.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 4b36a0f27f..3d4b4905b2 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -426,7 +426,7 @@ unpack() {
                fi
 
                # Skip any files bearing unsupported suffixes.
-               if [[ -v 'suffix_by[$suffix]' ]]; then
+               if [[ ${suffix} && -v 'suffix_by[$suffix]' ]]; then
                        __vecho ">>> Unpacking ${f@Q} to ${PWD}"
                else
                        __vecho "=== Skipping unpack of ${f@Q}"

Reply via email to