commit:     4f916561b12ad14c144367b98082c2964d08cf07
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Thu Jun 26 03:28:57 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Jun 28 02:30:16 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=4f916561

Abort where XARGS is required but is unset or empty

Presently, the "compress-file" unit defines the compress_file()
function, and the "phase-functions-sh" unit, the __dyn_clean() function.
Both functions require for the 'XARGS' environment variable to have been
set in order to behave correctly. Employ the ${param:?} form of
expansion so as to abort if the variable is either unset or empty.

Owing to a general lack of error checking, the principal benefit of this
change is that the diagnostics are improved for the case that the code
is not running in an appropriate operating environment.

BEFORE

ecompress-file: line 49: -0: command not found

AFTER

ecompress-file: line 49: XARGS: parameter null or not set

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

 bin/ecompress-file     | 2 +-
 bin/phase-functions.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/bin/ecompress-file b/bin/ecompress-file
index 2916ecf171..43436a15a0 100755
--- a/bin/ecompress-file
+++ b/bin/ecompress-file
@@ -46,7 +46,7 @@ compress_file() {
        # complain and skip, gzip will prompt for input)
        if [[ ${PORTAGE_COMPRESS_SUFFIX} ]]; then
                printf '%s\0' "${@/%/${PORTAGE_COMPRESS_SUFFIX}}" \
-               | ${XARGS} -0 rm -f --
+               | ${XARGS:?} -0 rm -f --
        fi
 
        # forcibly break all hard links as some compressors whine about it

diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
index c3a051bb7b..4f865fdc87 100644
--- a/bin/phase-functions.sh
+++ b/bin/phase-functions.sh
@@ -324,7 +324,7 @@ __dyn_clean() {
                printf '%s\0' "${PORTAGE_BUILDDIR}" \
                | find0 -depth -type d -empty -print0 \
                | while read -rd ''; do [[ ${REPLY} != "${WORKDIR}"?(/*) ]] && 
printf '%s\0' "${REPLY}"; done \
-               | ${XARGS} -0 rmdir --
+               | ${XARGS:?} -0 rmdir --
        fi
 
        # Do not bind this to doebuild defined DISTDIR; don't trust doebuild, 
and if mistakes are made it'll

Reply via email to