commit:     8db7cd83fa5680aa5b5e25150fde7efc0098accc
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Mon Jun  9 11:37:38 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jun 11 03:26:17 2025 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=8db7cd83

isolated-functions.sh: don't run find(1) where the paths var is empty

Presently, the find0() function implements a fallback mode to cover
situations where the -files0-from primary is unavailable, thereby
retaining compatibility with the GitHub CI environment (which suffers
from an outdated version of findutils).

Consider the case where find0() is given no input. It will effectively
do nothing, successfully.

$ : | find0 -print; echo "$?"
0

However, if find0() determines that it needs to employ the fallback
mode, it may instead act as if "." is to be searched.

$ cd /etc/skel
$ : | find0 -print
.
./.bash_logout
./.bash_profile
./.bashrc

Though it is rather unlikely that anyone will ever commit code to
portage that is capable of exposing this discrepancy, I consider the
matter to be worth addressing. Do so by refraining from executing
find(1) in the case that the 'paths' array variable is empty.

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

 bin/isolated-functions.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 722d92adb7..ceba971ae5 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -715,7 +715,9 @@ find0() {
                                shift
                        done
                        mapfile -td '' paths
-                       find "${opts[@]}" "${paths[@]}" "$@"
+                       if (( ${#paths[@]} )); then
+                               find "${opts[@]}" "${paths[@]}" "$@"
+                       fi
                }
        fi
 

Reply via email to