commit: e61b3bc230db0bfa2e7ca4c72915ac5154bf73cd
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sat Jul 27 19:55:48 2024 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri May 30 08:14:19 2025 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=e61b3bc2
phase-helpers.sh: use $# to check the argument count in unpack()
Because that is the proper way to do it. [[ -z "$*" ]] is simply
nonsense. If the intention was to defend against empty arguments then it
does no such thing; such a check would be easily circumvented by
specifying at least two arguments, be they empty or not. It is also
sensitive to the value of IFS.
Besides, if the empty string is encountered then unpacking will fail
anyway. In that event, so be it. Render the diagnostic message
indicating commencement of unpacking more useful by expanding the
filename with ${param@Q} expansion. Such is acceptable, given a target
of bash 4.4.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/phase-helpers.sh | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/bin/phase-helpers.sh b/bin/phase-helpers.sh
index 41175886dd..ec3316c176 100644
--- a/bin/phase-helpers.sh
+++ b/bin/phase-helpers.sh
@@ -333,7 +333,9 @@ unpack() {
local suffix
local f
- [[ -z "$*" ]] && die "Nothing passed to the 'unpack' command"
+ if (( $# == 0 )); then
+ die "unpack: too few arguments (got 0; expected at least 1)"
+ fi
__unpack_tar() {
local inner_suffix
@@ -396,13 +398,13 @@ unpack() {
fi
if [[ -n ${suffix_known} ]]; then
- __vecho ">>> Unpacking ${f} to ${PWD}"
+ __vecho ">>> Unpacking ${f@Q} to ${PWD}"
else
- __vecho "=== Skipping unpack of ${f}"
+ __vecho "=== Skipping unpack of ${f@Q}"
continue
fi
- myfail="unpack: failure unpacking ${f}"
+ myfail="unpack: failure unpacking ${f@Q}"
case ${suffix,,} in
tar)
tar xof "${srcdir}${f}" || die "${myfail}"