commit: 781732d87525469e311732d5418ffb0f3e419da8
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sat Jun 7 14:22:26 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Jun 7 22:54:14 2025 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=781732d8
ecompress: refine the error handling of fix_symlinks()
If either rm(1) or ln(1) fails, refrain from processing any outstanding
symlinks. Instead, return false immediately.
If find(1) fails, refrain from invoking die(). Instead, have the parent
shell wait for the enclosing process substitution to conclude before
returning false. To accomplish this, the wait builtin is invoked in a
manner that is acceptable as of bash >=4.4.
Drop the 'ret' variable, for it is no longer required.
It should be noted that the responsibility of throwing an exception is
already assumed by the calling context. That is, if fix_symlinks()
returns false for any reason, an exception shall be thrown.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/ecompress | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/bin/ecompress b/bin/ecompress
index 6ff956bc6b..7e13c182f4 100755
--- a/bin/ecompress
+++ b/bin/ecompress
@@ -132,7 +132,7 @@ guess_suffix() {
}
fix_symlinks() {
- local something_changed brokenlink newdest olddest ret i
+ local something_changed brokenlink newdest olddest i
# Repeat until nothing changes, in order to handle multiple
# levels of indirection (see bug #470916).
@@ -151,9 +151,12 @@ fix_symlinks() {
something_changed=1
rm -f -- "${brokenlink}" \
- && ln -snf -- "${newdest}"
"${brokenlink}${PORTAGE_COMPRESS_SUFFIX}"
- ((ret|=$?))
- done < <(printf '%s\0' "${ED}" | find0 -type l -print0 || die)
+ && ln -snf -- "${newdest}"
"${brokenlink}${PORTAGE_COMPRESS_SUFFIX}" \
+ || return
+ done < <(printf '%s\0' "${ED}" | find0 -type l -print0)
+
+ # Check whether the invocation of find(1) succeeded.
+ wait "$!" || return
if (( ! something_changed )); then
break
@@ -164,8 +167,6 @@ fix_symlinks() {
break
fi
done
-
- return ${ret}
}
if [[ -z $1 ]] ; then