commit: 4370f6178e4374ac5031ca16aa545f46e2156850
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Wed Aug 10 23:35:31 2022 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Jun 7 22:54:08 2025 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=4370f617
ecompress: routinely employ an explict arithmetic context
Idiomatically employ the (( … )) command. Also, evaluate the
'something_changed' variable in the arithmetic context.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/ecompress | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/bin/ecompress b/bin/ecompress
index 1f7bc7be1c..aa237f7d67 100755
--- a/bin/ecompress
+++ b/bin/ecompress
@@ -18,7 +18,7 @@ do_ignore() {
fi
done
- if [[ ${#skip_dirs[@]} -gt 0 ]]; then
+ if (( ${#skip_dirs[@]} )); then
while read -r -d '' skip; do
skip=${skip%.ecompress}
printf -- '%s\n' "${skip#${D%/}}" >>
"${T}/.ecompress_skip_files" || die
@@ -46,7 +46,7 @@ do_queue() {
fi
done
- if [[ ${#find_args[@]} -gt 0 ]]; then
+ if (( ${#find_args[@]} )); then
find_args+=( -type f )
[[ -n ${PORTAGE_DOCOMPRESS_SIZE_LIMIT} ]] &&
find_args+=( -size "+${PORTAGE_DOCOMPRESS_SIZE_LIMIT}c"
)
@@ -77,7 +77,7 @@ do_queue() {
>> "${path}.ecompress" || die
done < <(find "${find_args[@]}" -print0 || die)
- if [[ ${#collisions[@]} -gt 0 ]]; then
+ if (( ${#collisions[@]} )); then
eqawarn "QA Notice: Colliding files found by ecompress:"
eqawarn
for x in "${!collisions[@]}"; do
@@ -121,7 +121,7 @@ fix_symlinks() {
# Repeat until nothing changes, in order to handle multiple
# levels of indirection (see bug #470916).
while true ; do
- something_changed=
+ something_changed=0
while read -r -d $'\0' brokenlink ; do
[[ -e ${brokenlink} ]] && continue
@@ -133,16 +133,15 @@ fix_symlinks() {
[[ -f "${brokenlink%/*}/${newdest}" ]] ||
continue
fi
- something_changed=${brokenlink}
+ something_changed=1
rm -f "${brokenlink}" &&
ln -snf "${newdest}"
"${brokenlink}${PORTAGE_COMPRESS_SUFFIX}"
((ret|=$?))
done < <(find "${ED}" -type l -print0 || die)
- [[ -n ${something_changed} ]] || break
- (( indirection++ ))
-
- if (( indirection >= 100 )) ; then
+ if (( ! something_changed )); then
+ break
+ elif (( ++indirection >= 100 )); then
# Protect against possibility of a bug triggering an
endless loop.
eerror "ecompress: too many levels of indirection for" \
"'${something_changed#${ED%/}}'"
@@ -162,7 +161,7 @@ if ! ___eapi_has_prefix_variables; then
ED=${D} EPREFIX=
fi
-while [[ $# -gt 0 ]] ; do
+while (( $# )); do
case $1 in
--ignore)
shift
@@ -222,7 +221,7 @@ if [[ -s ${T}/.ecompress_had_precompressed ]]; then
n=0
while read -r f; do
eqawarn " ${f}"
- if [[ $(( n++ )) -eq 10 ]]; then
+ if (( ++n == 10 )); then
eqawarn " ..."
break
fi