commit: 3994c9308f00d0a87f7c0d8404ce209c0a487f71
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sun Jun 22 21:05:24 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Jun 23 10:37:08 2025 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=3994c930
emerge-webrsync: clarify the handling of DISTDIR in main()
This commit aims to clarify the handling of the 'DISTDIR' variable in
the main function(). The exact changes are described herewith.
Refrain from checking the value of the 'keep' key in the 'opt' array
twice.
In the event that the --keep option was not specified, refrain from
executing mkdir(1) with the value of 'DISTDIR' as an operand. Also,
refrain from testing whether the value of 'DISTDIR' is a writable path.
To do either of these things is unnecessary because it is guaranteed
that mktemp(1) will already have succeeded.
In the event that the --keep option was specified, execute mkdir(1) but
also check that it succeeds, exiting the program if it does not.
Employ the ${param@Q} form of expansion in the course of incorporating
the value of 'DISTDIR' into a diagnostic message. Doing so 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/emerge-webrsync | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
index bd8b1f1791..ca84d4498b 100755
--- a/bin/emerge-webrsync
+++ b/bin/emerge-webrsync
@@ -67,11 +67,10 @@ main() {
&& cd -- "${tmpdir}" \
|| exit
- (( opt[keep] )) || DISTDIR=${tmpdir}
- mkdir -p -- "${DISTDIR}"
-
- if (( opt[keep] )) && [[ ! -w ${DISTDIR} ]] ; then
- die "DISTDIR is not writable: ${DISTDIR}"
+ if (( ! opt[keep] )); then
+ DISTDIR=${tmpdir}
+ elif mkdir -p -- "${DISTDIR}" || exit; [[ ! -w ${DISTDIR} ]]; then
+ die "DISTDIR is not writable: ${DISTDIR@Q}"
fi
# This is a sanity check to help prevent people like funtoo users